Class NotificationService

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

public class NotificationService extends Object

A NotificationService subscribes to a Notifications container of the StreamLink user and allows the user to register a listener to be called when notifications are triggered or dismissed.

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

    • NotificationService

      public NotificationService(StreamLink streamLink)

      Creates a new NotificationService for the given StreamLink instance.

      Parameters:
      streamLink - the StreamLink that will be used to receive notifications and dismiss them.
  • Method Details

    • addListener

      public void addListener(NotificationListener listener)

      Adds a notification listener that will be called back when notifications are triggered or dismissed.

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

      public void removeListener(NotificationListener listener)

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

      Parameters:
      listener - The NotificationListener to be removed.
    • dismissNotification

      public void dismissNotification(Notification notification, ResultListener listener)

      Dismiss a notification for the current user.

      Parameters:
      notification - the notification to dismiss.
      listener - a ResultListener that will be called back to notify the user code whether the operation was sent to liberator successfully or not.