com.echomine.jabber
Class JabberPresenceService

java.lang.Object
  extended by com.echomine.jabber.JabberPresenceService
All Implemented Interfaces:
PresenceCode

public class JabberPresenceService
extends java.lang.Object
implements PresenceCode

Deals with all presence broadcast and receiving. The service offers easy ways to set your presence and also obtain presence.

NOTE: The presence works in conjunction with the Roster. Here is usually what happens. (1) When you subscribe to a presence, the user will appear in your roster (with no group and no nickname) automatically. (2) When you unsubscribe from a presence, the user will remain in the roster and must be explicitly removed. However, you will not receive any presence notification even though the person is in your roster.

The recommended way in adding and removing subscriptions is through the Roster first. Take a look at RosterService to see what the recommended way in adding and removing users.


Field Summary
 
Fields inherited from interface com.echomine.jabber.PresenceCode
SHOW_AWAY, SHOW_CHAT, SHOW_DO_NOT_DISTURB, SHOW_EXTENDED_AWAY, SHOW_ONLINE, TYPE_AVAILABLE, TYPE_INVISIBLE, TYPE_PROBE, TYPE_SUBSCRIBE, TYPE_SUBSCRIBED, TYPE_UNAVAILABLE, TYPE_UNSUBSCRIBE, TYPE_UNSUBSCRIBED
 
Constructor Summary
JabberPresenceService(JabberSession session)
           
 
Method Summary
 void acceptSubscribe(JabberPresenceMessage msg)
          when you receive a subscribe message, you may pass that subscribe message to this method to accept the subscription.
 void denySubscribe(JabberPresenceMessage msg)
          Takes a subscription request message and uses it to return a reply that declines the subscription request.
 void sendSubscribed(JID jid)
          sends a "subscribed" (not subscribe) message to the jid, essentially giving permission to the JID to know about your subscription.
 void sendUnsubscribed(JID jid)
          sends a "unsubscribed" (not unsubscribe) message to the jid, essentially cancelling any permission given previous to be subscribed to you.
 void setToAvailable(java.lang.String showState, java.lang.String status, boolean wait)
          sets status to available with optional show state and status line.
 void setToUnavailable()
          Sets the status to unavailable.
 void subscribe(JID jid)
          request to subscribe to a JID's presence.
 void unsubscribe(JID jid)
          unsubscribe from the jid so as not to receive further presence notifications from that jid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JabberPresenceService

public JabberPresenceService(JabberSession session)
Method Detail

setToAvailable

public void setToAvailable(java.lang.String showState,
                           java.lang.String status,
                           boolean wait)
                    throws SendMessageFailedException
sets status to available with optional show state and status line. The default priority is 0.

Parameters:
showState - optional parameter to set the show state (chat, away, extended away, etc), null if not setting a state
status - the status to set, or null if not setting a status text
wait - true if the caller wants to wait until there is a reply to the message
Throws:
SendMessageFailedException

setToUnavailable

public void setToUnavailable()
                      throws SendMessageFailedException
Sets the status to unavailable. Other users will no longer see you online

Throws:
SendMessageFailedException

subscribe

public void subscribe(JID jid)
               throws SendMessageFailedException
request to subscribe to a JID's presence. JID is an unique identifier for a user, resource, etc.

Throws:
SendMessageFailedException

unsubscribe

public void unsubscribe(JID jid)
                 throws SendMessageFailedException
unsubscribe from the jid so as not to receive further presence notifications from that jid.

Throws:
SendMessageFailedException

sendSubscribed

public void sendSubscribed(JID jid)
                    throws SendMessageFailedException
sends a "subscribed" (not subscribe) message to the jid, essentially giving permission to the JID to know about your subscription.

Throws:
SendMessageFailedException

sendUnsubscribed

public void sendUnsubscribed(JID jid)
                      throws SendMessageFailedException
sends a "unsubscribed" (not unsubscribe) message to the jid, essentially cancelling any permission given previous to be subscribed to you. This effectively makes it so the JID does not receive any of your presence info

Throws:
SendMessageFailedException

acceptSubscribe

public void acceptSubscribe(JabberPresenceMessage msg)
                     throws SendMessageFailedException
when you receive a subscribe message, you may pass that subscribe message to this method to accept the subscription. The method simply creates a "subscribed" message and fill in the information from the original message, and then send it out.

Parameters:
msg - the subscribe message sent by the remote
Throws:
SendMessageFailedException

denySubscribe

public void denySubscribe(JabberPresenceMessage msg)
                   throws SendMessageFailedException
Takes a subscription request message and uses it to return a reply that declines the subscription request.

Parameters:
msg - the subscribe message sent by the remote
Throws:
SendMessageFailedException


Copyright © 2001-2005 Echomine. All Rights Reserved.