Examples of Presence


Examples of org.jivesoftware.smack.packet.Presence

      RosterGroup rosterGroup = connection.getRoster().getGroup(groupname);
      int buddyEntries = rosterGroup.getEntryCount();
      int allBuddies = buddyEntries;
      for (Iterator I = rosterGroup.getEntries().iterator(); I.hasNext();) {
        RosterEntry entry = (RosterEntry) I.next();
        Presence presence = connection.getRoster().getPresence(entry.getUser());
        if (presence.getType() == Presence.Type.unavailable) buddyEntries--;
      }
      // final string looks like e.g. "(3/5)"
      StringBuilder sb = new StringBuilder(10);
      sb.append("(");
      sb.append(buddyEntries);
View Full Code Here

Examples of org.jivesoftware.smack.packet.Presence

   *
   * @param jid
   * @return get a presence for a specific user
   */
  protected String getUserPresence(String jid) {
    Presence presence = connection.getRoster().getPresence(jid);
    String imageName = "offline"; // default
    // mode == null is equals available!!
    if (presence.getMode() == null && presence.getType() == Presence.Type.available) imageName = Presence.Mode.available
        .toString();
    if (presence.getMode() != null) imageName = presence.getMode().toString();
    return imageName;
  }
View Full Code Here

Examples of org.jivesoftware.smack.packet.Presence

          GenericEventListener listener = listeners.get(username);
          if (listener == null) {
            log.warn("could not route presence event as presence listener is null for user: "+username);
          } else {
            listener.event(new InstantMessagingEvent(packet, "presence"));
            Presence presence = (Presence) packet;
            if (log.isDebug()) log.debug("routing presence event to controller of: "+presence.getTo());
          }
        } catch(Throwable th){
          log.warn("Presence package", th);
        }
      }
View Full Code Here

Examples of org.jivesoftware.smack.packet.Presence

   * helper method to trigger a presence update even if the server does not send
   * a presence packet itself (e.g. entering a test but no other buddies are online)
   * @param username
   */
  public void sendPresenceEvent(Presence.Type type, String username) {
    Presence presence = new Presence(type);
    presence.setTo(username);
    GenericEventListener listener = listeners.get(username);
    if (listener != null) {
      listener.event(new InstantMessagingEvent(presence, "presence"));
    }
  }
View Full Code Here

Examples of org.jivesoftware.smack.packet.Presence

    protected XMPPConnection connect(String resource) throws XMPPException {
      XMPPConnection c = new XMPPConnection(connConfig);
     
        c.connect();
        c.login(username, passwd, resource);       
        Presence presence = new Presence(Presence.Type.available);
        c.sendPacket(presence);
       
        return c;
    }
View Full Code Here

Examples of org.jivesoftware.smack.packet.Presence

                LOG.info("Logging in anonymously to XMPP on connection: " + connection);
                connection.loginAnonymously();
            }

            // now lets send a presence
            connection.sendPacket(new Presence(Presence.Type.AVAILABLE));
        }
        return connection;
    }
View Full Code Here

Examples of org.xmpp.packet.Presence

          if(result != null)
            manager.sendPacket(this,result);
        }
      }
    } else if(packet instanceof Presence) {
      Presence presence = (Presence)packet;
      if(presence.getTo().equals(componentJID)) {
        Kernel.debug(this,"Presence packet to: " + packet.getTo().toString() + " .. type: " + presence.getType(),3);
        if(presence.getType() == null || presence.getType() == Presence.Type.probe) { // available
          Presence reply = new Presence();
          reply.setTo(presence.getFrom());
          reply.setFrom(presence.getTo());
          manager.sendPacket(this,reply);
        } else if(presence.getType() == Presence.Type.subscribe) {
          Presence reply = new Presence(Presence.Type.subscribed);
          reply.setTo(presence.getFrom());
          reply.setFrom(presence.getTo());
          manager.sendPacket(this,reply);
        }
      } else {
        if(presence.getType() == Presence.Type.subscribe) {
          Presence reply = new Presence(Presence.Type.subscribed);
          reply.setTo(presence.getFrom());
          reply.setFrom(presence.getTo());
          manager.sendPacket(this,reply);
          //addSubscription(presence.getFrom().toBareJID(),presence.getTo().getNode());
        } else if(presence.getType() == null || presence.getType() == Presence.Type.probe) { // available
          //Kernel.debug(this,"Available presence packet to: " + presence.getTo().toString(),2);
          Presence reply = new Presence();
          reply.setTo(presence.getFrom());
          reply.setFrom(presence.getTo());
          manager.sendPacket(this,reply);
          //addSubscription(presence.getFrom().toBareJID(),presence.getTo().getNode());
        }
      }
    }
View Full Code Here

Examples of rocks.xmpp.core.stanza.model.client.Presence

        final PresenceListener presenceListener = new PresenceListener() {
            @Override
            public void handle(PresenceEvent e) {
                if (!e.isIncoming()) {
                    final Presence presence = e.getPresence();
                    if (presence.getTo() == null) {
                        waitForPlatform();
                        Platform.runLater(new Runnable() {
                            @Override
                            public void run() {
                                debugController.viewModel.presence.set(presence);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.