fi.hut.tml.xsmiles.protocol.wesahmi
Class Subscriber

java.lang.Object
  extended byfi.hut.tml.xsmiles.protocol.wesahmi.Subscriber

public class Subscriber
extends java.lang.Object


Nested Class Summary
static interface Subscriber.MessageListener
           
 
Constructor Summary
Subscriber(java.lang.String sipAddress)
           
Subscriber(java.lang.String sipAddress, Subscriber.MessageListener listener)
           
 
Method Summary
 Notification checkForNotifications()
          Checks if there is a notification waiting.
 int registerToService(java.lang.String service, java.lang.String url)
          Registers to the local notification client daemon.
 boolean sendSubscriptionRefresh(int subscriptionId, java.lang.String body)
          Sends data given by caller to notification server.
 boolean startService()
          Starts the subscriber service.
 void stopService()
          Stops the subscriber service
 boolean unregisterFromService(int id)
          Unregisters from the local notification client daemon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Subscriber

public Subscriber(java.lang.String sipAddress)
Parameters:
sipAddress - SIP-address used for subscriptions

Subscriber

public Subscriber(java.lang.String sipAddress,
                  Subscriber.MessageListener listener)
Parameters:
sipAddress - SIP-address used for subscriptions
Method Detail

startService

public boolean startService()
Starts the subscriber service. If listener object was given to class constructor a thread is started for handling incoming messages. Otherwise checkForNotifications should be used for polling incoming messages.

Returns:
true if service was started.

stopService

public void stopService()
Stops the subscriber service


registerToService

public int registerToService(java.lang.String service,
                             java.lang.String url)
                      throws java.io.IOException
Registers to the local notification client daemon. After the registration subscriber will receive notification from the service it has subscribe.

Parameters:
service - service name that subscriber is interested
url - url of the service that subscriber is interested (optional)
Returns:
registration identifier. 0 if registration fails.
Throws:
java.io.IOException

unregisterFromService

public boolean unregisterFromService(int id)
                              throws java.io.IOException
Unregisters from the local notification client daemon.

Parameters:
id - id of the service
Returns:
true if unregistration succeeded.
Throws:
java.io.IOException

checkForNotifications

public Notification checkForNotifications()
                                   throws java.io.IOException
Checks if there is a notification waiting.

Returns:
true if there was a notification.
Throws:
java.io.IOException

sendSubscriptionRefresh

public boolean sendSubscriptionRefresh(int subscriptionId,
                                       java.lang.String body)
                                throws java.io.IOException
Sends data given by caller to notification server. Any data can be sent and interpretting the data is responsibility of the receiver. This method can be used for example to fetch data from server if server has sent a notification telling that it has data waiting to be fetched. This method also refreshes the subscription and without the body can be used to only refreshing the subscription.

Parameters:
body - Data which caller wants to send to notification server
Returns:
true if the query was sent to server.
Throws:
java.io.IOException


X-Smiles 1.2