本文整理汇总了Java中org.jivesoftware.smackx.packet.OfflineMessageRequest类的典型用法代码示例。如果您正苦于以下问题:Java OfflineMessageRequest类的具体用法?Java OfflineMessageRequest怎么用?Java OfflineMessageRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OfflineMessageRequest类属于org.jivesoftware.smackx.packet包,在下文中一共展示了OfflineMessageRequest类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteMessages
import org.jivesoftware.smackx.packet.OfflineMessageRequest; //导入依赖的package包/类
/**
* Deletes the specified list of offline messages. The request will include the list of
* stamps that uniquely identifies the offline messages to delete.
*
* @param nodes the list of stamps that uniquely identifies offline message.
* @throws XMPPException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
*/
public void deleteMessages(List<String> nodes) throws XMPPException {
OfflineMessageRequest request = new OfflineMessageRequest();
for (String node : nodes) {
OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node);
item.setAction("remove");
request.addItem(item);
}
// Filter packets looking for an answer from the server.
PacketFilter responseFilter = new PacketIDFilter(request.getPacketID());
PacketCollector response = connection.createPacketCollector(responseFilter);
// Send the deletion 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());
}
}
示例2: deleteMessages
import org.jivesoftware.smackx.packet.OfflineMessageRequest; //导入依赖的package包/类
/**
* Deletes all offline messages of the user.
*
* @throws XMPPException
* If the user is not allowed to make this request or the server
* does not support offline message retrieval.
*/
public void deleteMessages() throws XMPPException {
OfflineMessageRequest request = new OfflineMessageRequest();
request.setPurge(true);
// Filter packets looking for an answer from the server.
PacketFilter responseFilter = new PacketIDFilter(request.getPacketID());
PacketCollector response = connection
.createPacketCollector(responseFilter);
// Send the deletion 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());
}
}
示例3: getMessages
import org.jivesoftware.smackx.packet.OfflineMessageRequest; //导入依赖的package包/类
/**
* Returns an Iterator with all the offline <tt>Messages</tt> of the user. The returned offline
* messages will not be deleted from the server. Use {@link #deleteMessages(java.util.List)}
* to delete the messages.
*
* @return an Iterator with all the offline <tt>Messages</tt> of the user.
* @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() throws XMPPException {
List<Message> messages = new ArrayList<Message>();
OfflineMessageRequest request = new OfflineMessageRequest();
request.setFetch(true);
// 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
PacketCollector messageCollector = connection.createPacketCollector(packetFilter);
// 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();
}
示例4: getMessages
import org.jivesoftware.smackx.packet.OfflineMessageRequest; //导入依赖的package包/类
/**
* Returns an Iterator with all the offline <tt>Messages</tt> of the user.
* The returned offline messages will not be deleted from the server. Use
* {@link #deleteMessages(java.util.List)} to delete the messages.
*
* @return an Iterator with all the offline <tt>Messages</tt> of the user.
* @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() throws XMPPException {
List<Message> messages = new ArrayList<Message>();
OfflineMessageRequest request = new OfflineMessageRequest();
request.setFetch(true);
// 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
PacketCollector messageCollector = connection
.createPacketCollector(packetFilter);
// 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();
}