public class NotifyRequestextends SOAPRequest
Represents a UPnP event notification request.

This class extends SOAPRequest to handle GENA (General Event Notification Architecture) NOTIFY messages sent by UPnP devices to inform subscribers about state variable changes. It manages the creation and parsing of event notification messages.

Key features:

  • Event notification message creation and parsing
  • Property set and property XML structure handling
  • SID (Subscription ID) and SEQ (sequence number) management
  • NT (Notification Type) and NTS (Notification Sub-Type) headers
  • Multi-property change notifications

This class is used by UPnP devices to send event notifications to subscribed control points, informing them of changes in service state variables. It handles both single and multiple property changes in a single notification message.

  • Field Details

  • Constructor Details

    • NotifyRequest

      public NotifyRequest()
      Creates an empty GENA notification request.
    • NotifyRequest

      public NotifyRequest(HTTPRequest httpReq)
      Creates a notification request whose headers come from a received NOTIFY.
      Parameters:
      httpReq - the received NOTIFY request supplying the headers to parse
  • Method Details

    • setNT

      public void setNT(String value)
      Sets the notification type header.
      Parameters:
      value - the event notification type to send, normally NT.EVENT
    • setNTS

      public void setNTS(String value)
      Sets the notification sub-type header.
      Parameters:
      value - the notification sub-type to send, NTS.PROPCHANGE for a property change and NTS.ALIVE or NTS.BYEBYE for an advertisement
    • setSID

      public void setSID(String id)
      Sets the subscription identifier, adding the required uuid: prefix.
      Parameters:
      id - the subscription identifier to send, wrapped in the uuid: prefix the SID header requires
    • getSID

      public String getSID()
      Gets the subscription identifier with its uuid: prefix stripped.
      Returns:
      the bare subscription identifier with the uuid: prefix stripped, or "" when the request carries no SID header
    • setSEQ

      public void setSEQ(long value)
      Sets the event sequence number, wrapping it at 32 bits.
      Parameters:
      value - the event sequence number to send, which wraps at 32 bits as the GENA specification requires
    • getSEQ

      public long getSEQ()
      Gets the event sequence number from the header.
      Returns:
      the event sequence number from the header, or 0 when absent or not parseable as a decimal integer
    • setRequest

      public boolean setRequest(Subscriber sub, String varName, String value)
      Fills in the NOTIFY method, URI, headers and property set for one change.
      Parameters:
      sub - the subscriber to notify, supplying the delivery URL, host, port, path, subscription identifier and event counter
      varName - the name of the state variable that changed
      value - the new value of that state variable
      Returns:
      true once the NOTIFY method, URI, headers and property set body have been filled in
    • createPropertySetNode

      private Node createPropertySetNode(String varName, String value)
      Builds the propertyset element holding one named value.
      Parameters:
      varName - the state variable's name
      value - the new value
      Returns:
      the propertyset node
    • getVariableNode

      private Node getVariableNode()
      Finds the propertyset element in the request body.
      Returns:
      the node, null if the body has none
    • getProperty

      private Property getProperty(Node varNode)
      Reads a Property element out of a variable node.
      Parameters:
      varNode - the variable node to read, null yields an empty property
      Returns:
      the property, never null but empty if there was nothing to read
    • getPropertyList

      public PropertyList getPropertyList()
      Reads the changed variables carried in the notification body.
      Returns:
      the changed variables carried in the body, or an empty list when the request has no envelope or no properties to report