Java 类org.jivesoftware.smackx.packet.OfflineMessageInfo 实例源码

项目:EIM    文件:OfflineMessageManager.java   
/**
 * Returns an Iterator with the offline <tt>Messages</tt> whose stamp matches the specified
 * request. The request will include the list of stamps that uniquely identifies
 * the offline messages to retrieve. The returned offline messages will not be deleted
 * from the server. Use {@link #deleteMessages(java.util.List)} to delete the messages.
 *
 * @param nodes the list of stamps that uniquely identifies offline message.
 * @return an Iterator with the offline <tt>Messages</tt> that were received as part of
 *         this request.
 * @throws XMPPException If the user is not allowed to make this request or the server does
 *                       not support offline message retrieval.
 */
public Iterator<Message> getMessages(final List<String> nodes) throws XMPPException {
    List<Message> messages = new ArrayList<Message>();
    OfflineMessageRequest request = new OfflineMessageRequest();
    for (String node : nodes) {
        OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
        item.setAction("view");
        request.addItem(item);
    }
    // Filter packets looking for an answer from the server.
    PacketFilter responseFilter = new PacketIDFilter(request.getPacketID());
    PacketCollector response = connection.createPacketCollector(responseFilter);
    // Filter offline messages that were requested by this request
    PacketFilter messageFilter = new AndFilter(packetFilter, new PacketFilter() {
        public boolean accept(Packet packet) {
            OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",
                    namespace);
            return nodes.contains(info.getNode());
        }
    });
    PacketCollector messageCollector = connection.createPacketCollector(messageFilter);
    // Send the retrieval request to the server.
    connection.sendPacket(request);
    // Wait up to a certain number of seconds for a reply.
    IQ answer = (IQ) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    response.cancel();

    if (answer == null) {
        throw new XMPPException("No response from server.");
    } else if (answer.getError() != null) {
        throw new XMPPException(answer.getError());
    }

    // Collect the received offline messages
    Message message = (Message) messageCollector.nextResult(
            SmackConfiguration.getPacketReplyTimeout());
    while (message != null) {
        messages.add(message);
        message =
                (Message) messageCollector.nextResult(
                        SmackConfiguration.getPacketReplyTimeout());
    }
    // Stop queuing offline messages
    messageCollector.cancel();
    return messages.iterator();
}
项目:androidPN-client.    文件:OfflineMessageManager.java   
/**
 * Returns an Iterator with the offline <tt>Messages</tt> whose stamp matches the specified
 * request. The request will include the list of stamps that uniquely identifies
 * the offline messages to retrieve. The returned offline messages will not be deleted
 * from the server. Use {@link #deleteMessages(java.util.List)} to delete the messages.
 *
 * @param nodes the list of stamps that uniquely identifies offline message.
 * @return an Iterator with the offline <tt>Messages</tt> that were received as part of
 *         this request.
 * @throws XMPPException If the user is not allowed to make this request or the server does
 *                       not support offline message retrieval.
 */
public Iterator<Message> getMessages(final List<String> nodes) throws XMPPException {
    List<Message> messages = new ArrayList<Message>();
    OfflineMessageRequest request = new OfflineMessageRequest();
    for (String node : nodes) {
        OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
        item.setAction("view");
        request.addItem(item);
    }
    // Filter packets looking for an answer from the server.
    PacketFilter responseFilter = new PacketIDFilter(request.getPacketID());
    PacketCollector response = connection.createPacketCollector(responseFilter);
    // Filter offline messages that were requested by this request
    PacketFilter messageFilter = new AndFilter(packetFilter, new PacketFilter() {
        public boolean accept(Packet packet) {
            OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",
                    namespace);
            return nodes.contains(info.getNode());
        }
    });
    PacketCollector messageCollector = connection.createPacketCollector(messageFilter);
    // Send the retrieval request to the server.
    connection.sendPacket(request);
    // Wait up to a certain number of seconds for a reply.
    IQ answer = (IQ) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    response.cancel();

    if (answer == null) {
        throw new XMPPException("No response from server.");
    } else if (answer.getError() != null) {
        throw new XMPPException(answer.getError());
    }

    // Collect the received offline messages
    Message message = (Message) messageCollector.nextResult(
            SmackConfiguration.getPacketReplyTimeout());
    while (message != null) {
        messages.add(message);
        message =
                (Message) messageCollector.nextResult(
                        SmackConfiguration.getPacketReplyTimeout());
    }
    // Stop queuing offline messages
    messageCollector.cancel();
    return messages.iterator();
}
项目:xmppsupport_v2    文件:OfflineMessageManager.java   
/**
 * Returns an Iterator with the offline <tt>Messages</tt> whose stamp
 * matches the specified request. The request will include the list of
 * stamps that uniquely identifies the offline messages to retrieve. The
 * returned offline messages will not be deleted from the server. Use
 * {@link #deleteMessages(java.util.List)} to delete the messages.
 * 
 * @param nodes
 *            the list of stamps that uniquely identifies offline message.
 * @return an Iterator with the offline <tt>Messages</tt> that were received
 *         as part of this request.
 * @throws XMPPException
 *             If the user is not allowed to make this request or the server
 *             does not support offline message retrieval.
 */
public Iterator<Message> getMessages(final List<String> nodes)
        throws XMPPException {
    List<Message> messages = new ArrayList<Message>();
    OfflineMessageRequest request = new OfflineMessageRequest();
    for (String node : nodes) {
        OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(
                node);
        item.setAction("view");
        request.addItem(item);
    }
    // Filter packets looking for an answer from the server.
    PacketFilter responseFilter = new PacketIDFilter(request.getPacketID());
    PacketCollector response = connection
            .createPacketCollector(responseFilter);
    // Filter offline messages that were requested by this request
    PacketFilter messageFilter = new AndFilter(packetFilter,
            new PacketFilter() {
                public boolean accept(Packet packet) {
                    OfflineMessageInfo info = (OfflineMessageInfo) packet
                            .getExtension("offline", namespace);
                    return nodes.contains(info.getNode());
                }
            });
    PacketCollector messageCollector = connection
            .createPacketCollector(messageFilter);
    // Send the retrieval request to the server.
    connection.sendPacket(request);
    // Wait up to a certain number of seconds for a reply.
    IQ answer = (IQ) response.nextResult(SmackConfiguration
            .getPacketReplyTimeout());
    // Stop queuing results
    response.cancel();

    if (answer == null) {
        throw new XMPPException("No response from server.");
    } else if (answer.getError() != null) {
        throw new XMPPException(answer.getError());
    }

    // Collect the received offline messages
    Message message = (Message) messageCollector
            .nextResult(SmackConfiguration.getPacketReplyTimeout());
    while (message != null) {
        messages.add(message);
        message = (Message) messageCollector.nextResult(SmackConfiguration
                .getPacketReplyTimeout());
    }
    // Stop queuing offline messages
    messageCollector.cancel();
    return messages.iterator();
}
项目:java-bells    文件:OfflineMessageManager.java   
/**
 * Returns an Iterator with the offline <tt>Messages</tt> whose stamp matches the specified
 * request. The request will include the list of stamps that uniquely identifies
 * the offline messages to retrieve. The returned offline messages will not be deleted
 * from the server. Use {@link #deleteMessages(java.util.List)} to delete the messages.
 *
 * @param nodes the list of stamps that uniquely identifies offline message.
 * @return an Iterator with the offline <tt>Messages</tt> that were received as part of
 *         this request.
 * @throws XMPPException If the user is not allowed to make this request or the server does
 *                       not support offline message retrieval.
 */
public Iterator<Message> getMessages(final List<String> nodes) throws XMPPException {
    List<Message> messages = new ArrayList<Message>();
    OfflineMessageRequest request = new OfflineMessageRequest();
    for (String node : nodes) {
        OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
        item.setAction("view");
        request.addItem(item);
    }
    // Filter packets looking for an answer from the server.
    PacketFilter responseFilter = new PacketIDFilter(request.getPacketID());
    PacketCollector response = connection.createPacketCollector(responseFilter);
    // Filter offline messages that were requested by this request
    PacketFilter messageFilter = new AndFilter(packetFilter, new PacketFilter() {
        public boolean accept(Packet packet) {
            OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",
                    namespace);
            return nodes.contains(info.getNode());
        }
    });
    PacketCollector messageCollector = connection.createPacketCollector(messageFilter);
    // Send the retrieval request to the server.
    connection.sendPacket(request);
    // Wait up to a certain number of seconds for a reply.
    IQ answer = (IQ) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    response.cancel();

    if (answer == null) {
        throw new XMPPException("No response from server.");
    } else if (answer.getError() != null) {
        throw new XMPPException(answer.getError());
    }

    // Collect the received offline messages
    Message message = (Message) messageCollector.nextResult(
            SmackConfiguration.getPacketReplyTimeout());
    while (message != null) {
        messages.add(message);
        message =
                (Message) messageCollector.nextResult(
                        SmackConfiguration.getPacketReplyTimeout());
    }
    // Stop queuing offline messages
    messageCollector.cancel();
    return messages.iterator();
}
项目:telegraph    文件:OfflineMessageManager.java   
/**
 * Returns an Iterator with the offline <tt>Messages</tt> whose stamp matches the specified
 * request. The request will include the list of stamps that uniquely identifies
 * the offline messages to retrieve. The returned offline messages will not be deleted
 * from the server. Use {@link #deleteMessages(java.util.List)} to delete the messages.
 *
 * @param nodes the list of stamps that uniquely identifies offline message.
 * @return an Iterator with the offline <tt>Messages</tt> that were received as part of
 *         this request.
 * @throws XMPPException If the user is not allowed to make this request or the server does
 *                       not support offline message retrieval.
 */
public Iterator<Message> getMessages(final List<String> nodes) throws XMPPException {
    List<Message> messages = new ArrayList<Message>();
    OfflineMessageRequest request = new OfflineMessageRequest();
    for (String node : nodes) {
        OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
        item.setAction("view");
        request.addItem(item);
    }
    // Filter packets looking for an answer from the server.
    PacketFilter responseFilter = new PacketIDFilter(request.getPacketID());
    PacketCollector response = connection.createPacketCollector(responseFilter);
    // Filter offline messages that were requested by this request
    PacketFilter messageFilter = new AndFilter(packetFilter, new PacketFilter() {
        public boolean accept(Packet packet) {
            OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",
                    namespace);
            return nodes.contains(info.getNode());
        }
    });
    PacketCollector messageCollector = connection.createPacketCollector(messageFilter);
    // Send the retrieval request to the server.
    connection.sendPacket(request);
    // Wait up to a certain number of seconds for a reply.
    IQ answer = (IQ) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    response.cancel();

    if (answer == null) {
        throw new XMPPException("No response from server.");
    } else if (answer.getError() != null) {
        throw new XMPPException(answer.getError());
    }

    // Collect the received offline messages
    Message message = (Message) messageCollector.nextResult(
            SmackConfiguration.getPacketReplyTimeout());
    while (message != null) {
        messages.add(message);
        message =
                (Message) messageCollector.nextResult(
                        SmackConfiguration.getPacketReplyTimeout());
    }
    // Stop queuing offline messages
    messageCollector.cancel();
    return messages.iterator();
}
项目:NewCommunication-Android    文件:OfflineMessageManager.java   
/**
 * Returns an Iterator with the offline <tt>Messages</tt> whose stamp matches the specified
 * request. The request will include the list of stamps that uniquely identifies
 * the offline messages to retrieve. The returned offline messages will not be deleted
 * from the server. Use {@link #deleteMessages(java.util.List)} to delete the messages.
 *
 * @param nodes the list of stamps that uniquely identifies offline message.
 * @return an Iterator with the offline <tt>Messages</tt> that were received as part of
 *         this request.
 * @throws XMPPException If the user is not allowed to make this request or the server does
 *                       not support offline message retrieval.
 */
public Iterator<Message> getMessages(final List<String> nodes) throws XMPPException {
    List<Message> messages = new ArrayList<Message>();
    OfflineMessageRequest request = new OfflineMessageRequest();
    for (String node : nodes) {
        OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
        item.setAction("view");
        request.addItem(item);
    }
    // Filter packets looking for an answer from the server.
    PacketFilter responseFilter = new PacketIDFilter(request.getPacketID());
    PacketCollector response = connection.createPacketCollector(responseFilter);
    // Filter offline messages that were requested by this request
    PacketFilter messageFilter = new AndFilter(packetFilter, new PacketFilter() {
        public boolean accept(Packet packet) {
            OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",
                    namespace);
            return nodes.contains(info.getNode());
        }
    });
    PacketCollector messageCollector = connection.createPacketCollector(messageFilter);
    // Send the retrieval request to the server.
    connection.sendPacket(request);
    // Wait up to a certain number of seconds for a reply.
    IQ answer = (IQ) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    response.cancel();

    if (answer == null) {
        throw new XMPPException("No response from server.");
    } else if (answer.getError() != null) {
        throw new XMPPException(answer.getError());
    }

    // Collect the received offline messages
    Message message = (Message) messageCollector.nextResult(
            SmackConfiguration.getPacketReplyTimeout());
    while (message != null) {
        messages.add(message);
        message =
                (Message) messageCollector.nextResult(
                        SmackConfiguration.getPacketReplyTimeout());
    }
    // Stop queuing offline messages
    messageCollector.cancel();
    return messages.iterator();
}