Package com.google.appengine.api.xmpp

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


        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        XMPPService xmpp = XMPPServiceFactory.getXMPPService();

        if (jid != null && command.equals("chat")) {
            Message message = new MessageBuilder()
                .withMessageType(MessageType.CHAT)
                .withRecipientJids(jid)
                .withBody(req.getParameter("chat_message"))
                .build();
            SendResponse sendResponse = xmpp.sendMessage(message);
View Full Code Here


        String answer = doArithmetic(message.getBody());
        if (answer == null) {
            answer = "I didn't understand: " + message.getBody();
        }

        Message reply = new MessageBuilder()
            .withRecipientJids(message.getFromJid())
            .withBody(answer)
            .build();
        SendResponse success = xmpp.sendMessage(reply);
        if (success.getStatusMap().get(message.getFromJid())
View Full Code Here

  }

  // For testing. Real requests are POST
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws IOException {
    Message message =new MessageBuilder()
        .withMessageType(MessageType.CHAT)
        .withFromJid(new JID(req.getParameter("from")))
        .withRecipientJids(new JID(req.getParameter("to")))
        .withBody(req.getParameter("body"))
        .build();
View Full Code Here

  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 :
View Full Code Here

  private boolean sendResponseToSender(XMPPService xmpp, JID sender, String messageBody) throws Exception {
    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;
      }
View Full Code Here

      // By XMPP
      // --Create the receiver and sender buddies
      JID toJid = new JID(getServletContext().getInitParameter("admin.gmail.email"));
      JID fromJid = new JID("filedownloadrelay@appspot.com");
      // --Create the message
      com.google.appengine.api.xmpp.Message xMsg = new MessageBuilder().withRecipientJids(toJid).withBody(trace).withMessageType(MessageType.NORMAL).withFromJid(fromJid).build();
      // --Get a XMPP service provider
      XMPPService xmpp = XMPPServiceFactory.getXMPPService();
      // --Send the message only if the receiver buddy is connected
      if (xmpp.getPresence(toJid).isAvailable()) {
        // Do not care about the message delivery status...
View Full Code Here

   * @param strMessage 要发送的消息内容
   */
  public static void sendMessage(JID fromJID, String strMessage)
  {
    XMPPService xmpp = XMPPServiceFactory.getXMPPService();
    Message MsgSend = new MessageBuilder()
        .withRecipientJids(fromJID)
        .withBody(strMessage)
        .build();
    if(xmpp.getPresence(fromJID).isAvailable())
    {
View Full Code Here

          JSONRequest request = new JSONRequest(json);
          JSONResponse response = agentFactory.receive(agentId,
              request, params);
         
          // reply to message
          Message msg = new MessageBuilder().withRecipientJids(from)
              .withFromJid(to).withBody(response.toString())
              .build();
          xmpp.sendMessage(msg);
        } else {
          throw new Exception(
              "Request does not contain a valid JSON-RPC request or response");
        }
      } catch (Exception err) {
        // generate JSON error response
        JSONRPCException jsonError = new JSONRPCException(
            JSONRPCException.CODE.INTERNAL_ERROR, err.getMessage());
        JSONResponse response = new JSONResponse(jsonError);
       
        // send exception as response
        Message msg = new MessageBuilder().withRecipientJids(from)
            .withFromJid(to).withBody(response.toString()).build();
        xmpp.sendMessage(msg);
      }
    }
  }
View Full Code Here

        b.append(document.getProperty("title"));
        b.append("' に");
        b.append(document.getProperty("memoCount"));
        b.append(" 件目が投稿されました.");
        Message message =
            new MessageBuilder()
                .withRecipientJids(new JID(ADMIN_EMAIL))
                .withBody(b.toString())
                .build();
        XMPPServiceFactory.getXMPPService().sendMessage(message);
    }
View Full Code Here

  // SENDING INSTANT MESSAGE

  public static SendResponse.Status sendIM(JID to, String msg) {
    return XMPP.xmppService.sendMessage(
          new MessageBuilder()
            .withRecipientJids(to)
            .withBody(msg)
            .build()
        ).getStatusMap()
          .get(to);
View Full Code Here

TOP

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

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.