org.fourthline.cling.model.gena

## Class LocalGENASubscription

- java.lang.Object
- - org.fourthline.cling.model.gena.GENASubscription<LocalService>
  - - org.fourthline.cling.model.gena.LocalGENASubscription

- All Implemented Interfaces:
    PropertyChangeListener, EventListener

      public abstract class LocalGENASubscription
      extends GENASubscription<LocalService>
      implements PropertyChangeListener

  An incoming subscription to a local service.

  Uses the `ServiceManager` to read the initial state of the `LocalService` on instantation. Typically, the `registerOnService()` method is called next, and from this point forward all `ServiceManager.EVENTED_STATE_VARIABLES` property change events are detected by this subscription. After moderation of state variable values (frequency and range of changes), the `GENASubscription.eventReceived()` method is called. Delivery of the event message to the subscriber is not part of this class, but the implementor of `GENASubscription.eventReceived()`.

  Author:
    Christian Bauer

- - ### Field Summary

    - ### Fields inherited from class org.fourthline.cling.model.gena.GENASubscription

      `actualDurationSeconds, currentSequence, currentValues, requestedDurationSeconds, service, subscriptionId`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `LocalGENASubscription(LocalService service, Integer requestedDurationSeconds, List<URL> callbackURLs)`
    `protected` | `LocalGENASubscription(LocalService service, List<URL> callbackURLs)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `end(CancelReason reason)` Removes a property change listener on the `ServiceManager`.
    `abstract void` | `ended(CancelReason reason)`
    `void` | `establish()`
    `List<URL>` | `getCallbackURLs()`
    `void` | `incrementSequence()`
    `protected Set<String>` | `moderateStateVariables(long currentTime, Collection<StateVariableValue> values)` Checks whether a state variable is moderated, and if this change is within the maximum rate and range limits.
    `void` | `propertyChange(PropertyChangeEvent e)` Moderates `ServiceManager.EVENTED_STATE_VARIABLES` events and state variable values, calls `GENASubscription.eventReceived()`.
    `void` | `registerOnService()` Adds a property change listener on the `ServiceManager`.
    `void` | `setSubscriptionDuration(Integer requestedDurationSeconds)`

    - ### Methods inherited from class org.fourthline.cling.model.gena.GENASubscription

      `established, eventReceived, getActualDurationSeconds, getCurrentSequence, getCurrentValues, getRequestedDurationSeconds, getService, getSubscriptionId, setActualSubscriptionDurationSeconds, setSubscriptionId, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### LocalGENASubscription

          protected LocalGENASubscription(LocalService service,
                               List<URL> callbackURLs)
                                   throws Exception

      Throws:
        `Exception`

    - #### LocalGENASubscription

          public LocalGENASubscription(LocalService service,
                               Integer requestedDurationSeconds,
                               List<URL> callbackURLs)
                                throws Exception

      Throws:
        `Exception`

  - ### Method Detail

    - #### getCallbackURLs

          public List<URL> getCallbackURLs()

    - #### registerOnService

          public void registerOnService()

      Adds a property change listener on the `ServiceManager`.

    - #### establish

          public void establish()

    - #### end

          public void end(CancelReason reason)

      Removes a property change listener on the `ServiceManager`.

    - #### propertyChange

          public void propertyChange(PropertyChangeEvent e)

      Moderates `ServiceManager.EVENTED_STATE_VARIABLES` events and state variable values, calls `GENASubscription.eventReceived()`.
      Specified by:
        `propertyChange` in interface `PropertyChangeListener`

    - #### moderateStateVariables

          protected Set<String> moderateStateVariables(long currentTime,
                                           Collection<StateVariableValue> values)

      Checks whether a state variable is moderated, and if this change is within the maximum rate and range limits.
      Parameters:
        `currentTime` - The current unix time.
        `values` - The state variable values to moderate.
      Returns:
        A collection of state variable values that although they might have changed, are excluded from the event.

    - #### incrementSequence

          public void incrementSequence()

    - #### setSubscriptionDuration

          public void setSubscriptionDuration(Integer requestedDurationSeconds)

      Parameters:
        `requestedDurationSeconds` - If `null` defaults to `UserConstants.DEFAULT_SUBSCRIPTION_DURATION_SECONDS`

    - #### ended

          public abstract void ended(CancelReason reason)

Copyright © 2014 4th Line GmbH, Switzerland. All Rights Reserved.