java.lang.Object
org.cybergarage.upnp.event.Subscriber

public class Subscriberextends Object
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 Details

    • SID

      private String SID
      /////////////////////////////////////////////
    • ifAddr

      private String ifAddr
      /////////////////////////////////////////////
    • deliveryURL

      private String deliveryURL
      /////////////////////////////////////////////
    • deliveryHost

      private String deliveryHost
      Host notifications are sent to.
    • deliveryPath

      private String deliveryPath
      Path notifications are sent to.
    • deliveryPort

      private int deliveryPort
      Port 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

      public String getSID()
      Returns the subscription ID.
      Returns:
      the subscription ID assigned by the service, null until one is set
    • setSID

      public void setSID(String sid)
      Records the subscription ID.
      Parameters:
      sid - the subscription ID the service issued
    • setInterfaceAddress

      public void setInterfaceAddress(String addr)
      Records the local interface address notifications go out from.
      Parameters:
      addr - the local interface address notifications are sent from
    • getInterfaceAddress

      public String getInterfaceAddress()
      Returns the local interface address.
      Returns:
      the local interface address, empty until one is set
    • getDeliveryURL

      public String getDeliveryURL()
      Returns the callback URL notifications are POSTed to.
      Returns:
      the callback URL notifications are POSTed to, empty until one is set
    • setDeliveryURL

      public void setDeliveryURL(String deliveryURL)
      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

      public String getDeliveryHost()
      Returns the host parsed from the delivery URL.
      Returns:
      the host parsed out of the delivery URL, empty until one is set
    • getDeliveryPath

      public String 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_VALUE for 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 by renew()
    • 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.