Package com.google.appengine.api.xmpp

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


   */
  public static final void sendMessage(JID jid, String msg){
   
    XMPPService xmpp = XMPPServiceFactory.getXMPPService();
   
    Presence presence = xmpp.getPresence(jid , new JID("talkfeed@appspot.com"));

   
    Logger log = Logger.getLogger(TalkService.class.getName());
    log.info(" send message to : " + jid.getId()
        + ". Presence : " + presence.isAvailable()
        + ". presence show : " + presence.getPresenceShow()
        + ". presence type : "+ presence.getPresenceType());
   
    //
    boolean isAvailable = UserPresence.isUserAvailable(jid.getId());
    if (isAvailable){
     
View Full Code Here


   * @throws IOException
   */
  public static final Presence getPresence(HttpServletRequest req) throws IOException{

    XMPPService xmpp = XMPPServiceFactory.getXMPPService();
    Presence presence = xmpp.parsePresence(req);
   
    Logger.getLogger("TalkService").info(
        " getPresenceFrom : " + presence.getFromJid().getId()  + "("
        + presence.isAvailable() + ")");
    /*
    user = TextTools.cleanJID(presence.getFromJid().getId());*/
    return presence;
  }
View Full Code Here

   
    //PRESENCE
    if(action.contains("presence")){
      UserManager um = new UserManager();
     
      Presence presence = TalkService.getPresence(req);
     
      String user = TextTools.cleanJID(presence.getFromJid().getId());
      um.setUserPresence(user, presence);
    }
   

  }
View Full Code Here

        log.info("PresenceServlet: ..." + req.getPathInfo());

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

        Presence presence = xmpp.parsePresence(req);
        JID userJID = presence.getFromJid();

        if (presence.getPresenceType() == PresenceType.AVAILABLE ||
            presence.getPresenceType() == PresenceType.UNAVAILABLE) {
            // Store the user's presence.
            Entity userEntity = MainPageServlet.getUserEntity(userJID);
            userEntity.setProperty("is_available",
                                   presence.getPresenceType() == PresenceType.AVAILABLE);

            // Interpret no show value or "none" as "chat".
            if (presence.getPresenceShow() == null ||
                presence.getPresenceShow() == PresenceShow.NONE) {
                userEntity.setProperty("presence_show", "chat");
            } else {
                userEntity.setProperty("presence_show",
                                       presence.getPresenceShow().toString().toLowerCase());
            }

            userEntity.setProperty("status_message", presence.getStatus());
            datastore.put(userEntity);

        } else if (presence.getPresenceType() == PresenceType.PROBE) {
            // Respond to the probe by sending the app's presence.
            Entity statusEntity = MainPageServlet.getStatusEntity();
            xmpp.sendPresence(userJID,
                              ((Boolean)statusEntity.getProperty("presence_available")) ?
                              PresenceType.AVAILABLE : PresenceType.UNAVAILABLE,
View Full Code Here

    processMessage(xmppService.parseMessage(req), res);
  }

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

TOP

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

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.