java.lang.Object
org.cybergarage.upnp.event.Subscriber
Represents a UPnP event subscriber.
This class encapsulates information about a control point that has subscribed to receive event notifications from a UPnP service. It manages the subscription lifecycle including timeout, renewal, and delivery URL information.
Key features:
- Subscription ID (SID) management
- Delivery URL and callback address handling
- Subscription timeout and renewal tracking
- Expiration checking and management
- Sequence number tracking for notifications
This class is used by UPnP services to maintain information about each subscriber, enabling targeted delivery of event notifications and management of subscription lifecycles including automatic cleanup of expired subscriptions.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringHost notifications are sent to.private StringPath notifications are sent to.private intPort notifications are sent to.private String/////////////////////////////////////////////private String/////////////////////////////////////////////private long/////////////////////////////////////////////private String/////////////////////////////////////////////private long/////////////////////////////////////////////private long/////////////////////////////////////////////Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionReturns the host parsed from the delivery URL.Returns the path parsed from the delivery URL.intReturns the port parsed from the delivery URL.Returns the callback URL notifications are POSTed to.Returns the local interface address.longReturns the notification count since the last renewal.getSID()Returns the subscription ID.longReturns when the subscription was last renewed.longReturns the subscription duration.voidIncrements the notification count, wrapping back to 1 at the maximum.booleanReturns whether the subscription duration has run out.voidrenew()Restarts the subscription clock and zeroes the notification count.voidsetDeliveryURL(String deliveryURL) Records the callback URL and caches its host, path and port.voidsetInterfaceAddress(String addr) Records the local interface address notifications go out from.voidsetNotifyCount(int cnt) Records the notification count.voidRecords the subscription ID.voidsetSubscriptionTime(long time) Records when the subscription started.voidsetTimeOut(long value) Records how long the subscription lasts.
Field Details
SID
/////////////////////////////////////////////ifAddr
/////////////////////////////////////////////deliveryURL
/////////////////////////////////////////////deliveryHost
Host notifications are sent to.deliveryPath
Path notifications are sent to.deliveryPort
private int deliveryPortPort notifications are sent to.timeOut
private long timeOut/////////////////////////////////////////////subscriptionTime
private long subscriptionTime/////////////////////////////////////////////notifyCount
private long notifyCount/////////////////////////////////////////////
Constructor Details
Subscriber
public Subscriber()Creates a subscription that is renewed as of now.
Method Details
getSID
Returns the subscription ID.- Returns:
- the subscription ID assigned by the service, null until one is set
setSID
Records the subscription ID.- Parameters:
sid- the subscription ID the service issued
setInterfaceAddress
Records the local interface address notifications go out from.- Parameters:
addr- the local interface address notifications are sent from
getInterfaceAddress
Returns the local interface address.- Returns:
- the local interface address, empty until one is set
getDeliveryURL
Returns the callback URL notifications are POSTed to.- Returns:
- the callback URL notifications are POSTed to, empty until one is set
setDeliveryURL
Records the callback URL and caches its host, path and port.- Parameters:
deliveryURL- the callback URL to POST to, also split into the cached host, path and port; an unparsable URL leaves those at their defaults
getDeliveryHost
Returns the host parsed from the delivery URL.- Returns:
- the host parsed out of the delivery URL, empty until one is set
getDeliveryPath
Returns the path parsed from the delivery URL.- Returns:
- the path parsed out of the delivery URL, empty until one is set
getDeliveryPort
public int getDeliveryPort()Returns the port parsed from the delivery URL.- Returns:
- the port parsed out of the delivery URL, 0 until one is set
getTimeOut
public long getTimeOut()Returns the subscription duration.- Returns:
- the subscription duration in seconds, or
Subscription.INFINITE_VALUEfor none
setTimeOut
public void setTimeOut(long value) Records how long the subscription lasts.- Parameters:
value- the duration in seconds from now, or INFINITE_VALUE for no expiry
isExpired
public boolean isExpired()Returns whether the subscription duration has run out.- Returns:
- true once the timeout has elapsed, false if it is infinite or still unexpired
getSubscriptionTime
public long getSubscriptionTime()Returns when the subscription was last renewed.- Returns:
- when the subscription was last renewed, in milliseconds since the epoch
setSubscriptionTime
public void setSubscriptionTime(long time) Records when the subscription started.- Parameters:
time- when the subscription starts, in milliseconds since the epoch
getNotifyCount
public long getNotifyCount()Returns the notification count since the last renewal.- Returns:
- the notification count since the last renewal, which wraps to 1 rather than overflow
setNotifyCount
public void setNotifyCount(int cnt) Records the notification count.- Parameters:
cnt- the notification count to record, as zeroed again byrenew()
incrementNotifyCount
public void incrementNotifyCount()Increments the notification count, wrapping back to 1 at the maximum.renew
public void renew()Restarts the subscription clock and zeroes the notification count.