local.ua
Class PresenceAgent

java.lang.Object
  |
  +--local.ua.PresenceAgent
All Implemented Interfaces:
org.zoolu.sip.dialog.NotifierDialogListener, org.zoolu.sip.dialog.SubscriberDialogListener

public class PresenceAgent
extends java.lang.Object
implements org.zoolu.sip.dialog.SubscriberDialogListener, org.zoolu.sip.dialog.NotifierDialogListener

Simple Presence Agent (PA).
It allows a user to subscribe for a presentity acting as presence watcher, or respond to subscription requests (accepting or refusiong the incoming watcher's requests) acting as presentity that watchers can subscribe for.
In the latter case, it simply acts as authorization entity for subscription events.


Field Summary
protected  PresenceAgentListener listener
          Presence listener
protected  org.zoolu.tools.Log log
          Event logger.
protected  org.zoolu.sip.dialog.NotifierDialog notifier_dialog
          NotifierDialog.
protected  org.zoolu.sip.provider.SipProvider sip_provider
          SipProvider
protected  org.zoolu.sip.dialog.SubscriberDialog subscriber_dialog
          SubscriberDialog.
protected  UserAgentProfile user_profile
          UserProfile
 
Constructor Summary
PresenceAgent(org.zoolu.sip.provider.SipProvider sip_provider, UserAgentProfile user_profile, PresenceAgentListener listener)
          Costructs a new PresenceAgent.
 
Method Summary
 void accept()
          Notify a watcher of "active" state.
 void activate()
          Notify a watcher of "active" state.
 void notify(java.lang.String state, int expires, java.lang.String content_type, java.lang.String body)
          Notify a watcher.
 void onDlgNotificationFailure(org.zoolu.sip.dialog.NotifierDialog dialog, int code, java.lang.String reason, org.zoolu.sip.message.Message msg)
          When a 300-699 response is received for a NOTIFY transaction.
 void onDlgNotificationSuccess(org.zoolu.sip.dialog.NotifierDialog dialog, int code, java.lang.String reason, org.zoolu.sip.message.Message msg)
          When a 2xx successfull final response is received for a NOTIFY transaction.
 void onDlgNotify(org.zoolu.sip.dialog.SubscriberDialog dialog, org.zoolu.sip.address.NameAddress target, org.zoolu.sip.address.NameAddress notifier, org.zoolu.sip.address.NameAddress contact, java.lang.String state, java.lang.String content_type, java.lang.String body, org.zoolu.sip.message.Message msg)
          When an incoming NOTIFY is received.
 void onDlgNotifyTimeout(org.zoolu.sip.dialog.NotifierDialog dialog)
          When NOTIFY transaction expires without a final response.
 void onDlgSubscribe(org.zoolu.sip.dialog.NotifierDialog dialog, org.zoolu.sip.address.NameAddress target, org.zoolu.sip.address.NameAddress subscriber, java.lang.String event, java.lang.String id, org.zoolu.sip.message.Message msg)
          When an incoming SUBSCRIBE is received.
 void onDlgSubscribeTimeout(org.zoolu.sip.dialog.SubscriberDialog dialog)
          When SUBSCRIBE transaction expires without a final response.
 void onDlgSubscriptionFailure(org.zoolu.sip.dialog.SubscriberDialog dialog, int code, java.lang.String reason, org.zoolu.sip.message.Message msg)
          When a 300-699 response is received for an SUBSCRIBE transaction.
 void onDlgSubscriptionSuccess(org.zoolu.sip.dialog.SubscriberDialog dialog, int code, java.lang.String reason, org.zoolu.sip.message.Message msg)
          When a 2xx successfull final response is received for an SUBSCRIBE transaction.
 void onDlgSubscriptionTerminated(org.zoolu.sip.dialog.SubscriberDialog dialog)
          When the dialog is terminated.
 void subscribe(java.lang.String presentity, int expires)
          Subscribes for a presentity.
 void terminate()
          Notify a watcher of "terminate" state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.zoolu.tools.Log log
Event logger.

user_profile

protected UserAgentProfile user_profile
UserProfile

sip_provider

protected org.zoolu.sip.provider.SipProvider sip_provider
SipProvider

subscriber_dialog

protected org.zoolu.sip.dialog.SubscriberDialog subscriber_dialog
SubscriberDialog.

notifier_dialog

protected org.zoolu.sip.dialog.NotifierDialog notifier_dialog
NotifierDialog.

listener

protected PresenceAgentListener listener
Presence listener
Constructor Detail

PresenceAgent

public PresenceAgent(org.zoolu.sip.provider.SipProvider sip_provider,
                     UserAgentProfile user_profile,
                     PresenceAgentListener listener)
Costructs a new PresenceAgent.
Method Detail

subscribe

public void subscribe(java.lang.String presentity,
                      int expires)
Subscribes for a presentity.

accept

public void accept()
Notify a watcher of "active" state.

activate

public void activate()
Notify a watcher of "active" state.

terminate

public void terminate()
Notify a watcher of "terminate" state.

notify

public void notify(java.lang.String state,
                   int expires,
                   java.lang.String content_type,
                   java.lang.String body)
Notify a watcher.

onDlgSubscriptionSuccess

public void onDlgSubscriptionSuccess(org.zoolu.sip.dialog.SubscriberDialog dialog,
                                     int code,
                                     java.lang.String reason,
                                     org.zoolu.sip.message.Message msg)
When a 2xx successfull final response is received for an SUBSCRIBE transaction.
Specified by:
onDlgSubscriptionSuccess in interface org.zoolu.sip.dialog.SubscriberDialogListener

onDlgSubscriptionFailure

public void onDlgSubscriptionFailure(org.zoolu.sip.dialog.SubscriberDialog dialog,
                                     int code,
                                     java.lang.String reason,
                                     org.zoolu.sip.message.Message msg)
When a 300-699 response is received for an SUBSCRIBE transaction.
Specified by:
onDlgSubscriptionFailure in interface org.zoolu.sip.dialog.SubscriberDialogListener

onDlgSubscribeTimeout

public void onDlgSubscribeTimeout(org.zoolu.sip.dialog.SubscriberDialog dialog)
When SUBSCRIBE transaction expires without a final response.
Specified by:
onDlgSubscribeTimeout in interface org.zoolu.sip.dialog.SubscriberDialogListener

onDlgSubscriptionTerminated

public void onDlgSubscriptionTerminated(org.zoolu.sip.dialog.SubscriberDialog dialog)
When the dialog is terminated.
Specified by:
onDlgSubscriptionTerminated in interface org.zoolu.sip.dialog.SubscriberDialogListener

onDlgNotify

public void onDlgNotify(org.zoolu.sip.dialog.SubscriberDialog dialog,
                        org.zoolu.sip.address.NameAddress target,
                        org.zoolu.sip.address.NameAddress notifier,
                        org.zoolu.sip.address.NameAddress contact,
                        java.lang.String state,
                        java.lang.String content_type,
                        java.lang.String body,
                        org.zoolu.sip.message.Message msg)
When an incoming NOTIFY is received.
Specified by:
onDlgNotify in interface org.zoolu.sip.dialog.SubscriberDialogListener

onDlgSubscribe

public void onDlgSubscribe(org.zoolu.sip.dialog.NotifierDialog dialog,
                           org.zoolu.sip.address.NameAddress target,
                           org.zoolu.sip.address.NameAddress subscriber,
                           java.lang.String event,
                           java.lang.String id,
                           org.zoolu.sip.message.Message msg)
When an incoming SUBSCRIBE is received.
Specified by:
onDlgSubscribe in interface org.zoolu.sip.dialog.NotifierDialogListener

onDlgNotifyTimeout

public void onDlgNotifyTimeout(org.zoolu.sip.dialog.NotifierDialog dialog)
When NOTIFY transaction expires without a final response.
Specified by:
onDlgNotifyTimeout in interface org.zoolu.sip.dialog.NotifierDialogListener

onDlgNotificationFailure

public void onDlgNotificationFailure(org.zoolu.sip.dialog.NotifierDialog dialog,
                                     int code,
                                     java.lang.String reason,
                                     org.zoolu.sip.message.Message msg)
When a 300-699 response is received for a NOTIFY transaction.
Specified by:
onDlgNotificationFailure in interface org.zoolu.sip.dialog.NotifierDialogListener

onDlgNotificationSuccess

public void onDlgNotificationSuccess(org.zoolu.sip.dialog.NotifierDialog dialog,
                                     int code,
                                     java.lang.String reason,
                                     org.zoolu.sip.message.Message msg)
When a 2xx successfull final response is received for a NOTIFY transaction.
Specified by:
onDlgNotificationSuccess in interface org.zoolu.sip.dialog.NotifierDialogListener