Package com.google.appengine.api.xmpp

Examples of com.google.appengine.api.xmpp.SendResponse


  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");
  }
View Full Code Here


    boolean sent = false;
    // Send the message only if the buddy is online
    if (xmpp.getPresence(sender).isAvailable()) {
      // Create a message container
      Message msg = new MessageBuilder().withRecipientJids(sender).withBody(messageBody.trim()).withFromJid(new JID(APPLICATION_JID)).withMessageType(MessageType.CHAT).build();
      SendResponse status = xmpp.sendMessage(msg);
      // Check delivery status
      if ((status.getStatusMap().get(sender) == SendResponse.Status.SUCCESS)) {
        sent = true;
      }
    }
    return sent;
  }
View Full Code Here

        .withRecipientJids(fromJID)
        .withBody(strMessage)
        .build();
    if(xmpp.getPresence(fromJID).isAvailable())
    {
      SendResponse success = xmpp.sendMessage(MsgSend);
      if(success.getStatusMap().get(fromJID) != SendResponse.Status.SUCCESS//发送失败,重试一次
      {
        success = xmpp.sendMessage(MsgSend);
      }
    }
  }
View Full Code Here

        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);
    }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.xmpp.SendResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.