Class TriggerService

java.lang.Object
com.caplin.streamlink.alerts.TriggerService

public class TriggerService extends Object

A TriggerService subscribes to the Triggers of a StreamLink user and allows the user to register a listener to be called back when triggers are added, removed or modified.

The TriggerService also allows the user to add and remove triggers.

When trigger conditions are met, notifications will be fired. Notifications can be handled by creating a NotificationService and registering for notification callbacks.

The service itself does not subscribe to anything unless listeners are added to it. For every listener added one subscription is being issued. These subscriptions induce the service state for the associated listeners. Therefore the service states can vary for different listeners. If the reference to the service is removed without removing all listeners beforehand, open subscriptions will stay around forever. To avoid that, remove all listeners before removing the service.

  • Constructor Details

    • TriggerService

      public TriggerService(StreamLink streamLink)

      Creates a new TriggerService for the given StreamLink instance.

      Parameters:
      streamLink - the StreamLink that will be used to send and retrieve triggers from the Liberator.
  • Method Details

    • addListener

      public void addListener(TriggerListener listener)

      Adds a trigger listener that will be called back when triggers are added and removed.

      Parameters:
      listener - - The TriggerListener to be added.
    • removeListener

      public void removeListener(TriggerListener listener)

      Removes a previously added trigger listener, callbacks to this listener will be stopped.

      Parameters:
      listener - - The TriggerListener to be removed.
    • addTrigger

      public Trigger addTrigger(String subject, String condition, Map<String,String> extraParams, ResultListener listener)

      Add a new trigger for the current user.

      Parameters:
      subject - the rttp subject of this trigger.
      condition - the trigger condition, for more details on the format of the condition string, please see the StreamLink Overview document.
      extraParams - a map of extra parameters to be added to the trigger.
      listener - a ResultListener that will be called back to notify the user code of the result of this operation.
      Returns:
      the trigger that has been created.
    • enableTrigger

      public Trigger enableTrigger(Trigger trigger, ResultListener listener)

      Enables a trigger in the system.

      Parameters:
      trigger - the Trigger that should be enabled.
      listener - a ResultListener that will be called back to notify the user code of the result of this operation.
    • disableTrigger

      public Trigger disableTrigger(Trigger trigger, ResultListener listener)

      Disables a trigger in the system.

      Parameters:
      trigger - the Trigger that should be disabled.
      listener - a ResultListener that will be called back to notify the user code of the result of this operation.
    • removeTrigger

      public void removeTrigger(Trigger trigger, ResultListener listener)

      Removes a trigger from the system.

      Parameters:
      trigger - the Trigger that should be removed.
      listener - a ResultListener that will be called back to notify the user code of the result of this operation.