本文整理汇总了Java中com.google.appengine.api.xmpp.SendResponse类的典型用法代码示例。如果您正苦于以下问题:Java SendResponse类的具体用法?Java SendResponse怎么用?Java SendResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SendResponse类属于com.google.appengine.api.xmpp包,在下文中一共展示了SendResponse类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendXmppMessage
import com.google.appengine.api.xmpp.SendResponse; //导入依赖的package包/类
public static boolean sendXmppMessage(String p_jabberId, ChatMessage p_chatMessage)
{
boolean messageSent = false;
if( p_jabberId != null )
{
JID jid = new JID(p_jabberId);
String msgBody = "[" + p_chatMessage.getFromPseudo() + "] " + p_chatMessage.getText();
Message msg = new MessageBuilder()
.withRecipientJids(jid)
.withBody(msgBody)
.build();
XMPPService xmpp = XMPPServiceFactory.getXMPPService();
SendResponse status = xmpp.sendMessage(msg);
messageSent = (status.getStatusMap().get(jid) == SendResponse.Status.SUCCESS);
}
return messageSent;
}
示例2: testXmppSendMessageAndReceiveDefaultJid
import com.google.appengine.api.xmpp.SendResponse; //导入依赖的package包/类
@Test
public void testXmppSendMessageAndReceiveDefaultJid() {
assumeEnvironment(Environment.APPSPOT);
JID fromJID = new JID(appId + "@" + xmppServer);
// We're sending messages to ourselves, so toJID and fromJID are the same.
@SuppressWarnings("UnnecessaryLocalVariable")
JID toJID = fromJID;
MessageBuilder builder = new MessageBuilder();
builder.withMessageType(MessageType.valueOf("CHAT"));
builder.withFromJid(fromJID);
builder.withRecipientJids(toJID);
String testBody = TEST_BODY + System.currentTimeMillis();
builder.withBody(testBody);
builder.asXml(false);
Message msg = builder.build();
SendResponse response = xmppService.sendMessage(msg);
assertNotNull("expected a response", response);
assertEquals(1, response.getStatusMap().size());
assertEquals(SendResponse.Status.SUCCESS, response.getStatusMap().get(toJID));
verifyChatReceivedWithBody(testBody);
}
示例3: processMessage
import com.google.appengine.api.xmpp.SendResponse; //导入依赖的package包/类
public void processMessage(Message message, HttpServletResponse res) throws IOException {
JID fromId = message.getFromJid();
Presence presence = xmppService.getPresence(fromId);
String presenceString = presence.isAvailable() ? "" : "not ";
SendResponse response = xmppService.sendMessage(
new MessageBuilder().
withBody(message.getBody() + " (you are " + presenceString + "available)").
withRecipientJids(fromId).
build());
for (Map.Entry<JID, SendResponse.Status> entry :
response.getStatusMap().entrySet()) {
res.getWriter().println(entry.getKey() + "," + entry.getValue() + "<br>");
}
res.getWriter().println("processed");
}