Package com.caplin.streamlink.alerts


package com.caplin.streamlink.alerts

The interfaces within this package provide the functionality of Triggers and Notifications.

The TriggerService class allows the list of triggers to be monitored and modified.

The NotificationService class allows the user to listen and dismiss notifications.

The Trigger- as well as the NotificationService don't maintain a state. Only if a Listener is added to them, an internal subscription to a trigger/notification container is issued for each listener and kept alive for the time the listener is active. The Service status depends on this subscription and can be different for different listeners. In order to terminate a service properly, all listeners need to be removed from it. When a listener is removed from the service, it's internal subscription is terminated as well and the listener will no longer receive any updates

A trivial example of how to create and terminate services:

import com.caplin.streamlink.ServiceStatus;
import com.caplin.streamlink.StreamLink;
import com.caplin.streamlink.alerts.*;

public class CreateAndTerminateServiceSnippet
{
        
        private final TriggerService triggerService;
        private final NotificationService notificationService;
        private TriggerListener triggerListener = new MyTriggerListener();
        private NotificationListener notificationListener = new MyNotificationListener();
        
        public CreateAndTerminateServiceSnippet(StreamLink streamLink)
        {
                triggerService = new TriggerService(streamLink);
                notificationService = new NotificationService(streamLink);
                //services are now operational and can process operations
                
                triggerService.addListener(triggerListener);
                notificationService.addListener(notificationListener);
                //services now have a subscription to the notification containers
                //and listeners will be notified of triggers
                
                triggerService.removeListener(triggerListener);
                notificationService.removeListener(notificationListener);
                //services have terminated the internal subscriptions for the listeners
                //it's now safe to delete the reference to them
        }
        
        private class MyTriggerListener implements TriggerListener
        {
                @Override public void onTriggerAdded(Trigger trigger)
                {
                        
                }
                
                @Override public void onTriggerRemoved(Trigger trigger)
                {
                        
                }
                
                @Override public void onTriggerUpdated(Trigger trigger)
                {
                        
                }
                
                @Override public void onServiceStatus(ServiceStatus status)
                {
                        
                }
        }
        
        private class MyNotificationListener implements NotificationListener
        {
                @Override public void onNotification(Notification notification)
                {
                        
                }
                
                @Override public void onNotificationRemoved(Notification notification)
                {
                        
                }
                
                @Override public void onServiceStatus(ServiceStatus status)
                {
                        
                }
        }
}

  • Class
    Description
    A Notification is an object that can be sent to notify a user of a particular event.
    Interface that should be implemented to receive notification change callbacks from the NotificationProvider
    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.
    An interface that can be registered to be called back when an operation completes.
    A Trigger is an object associated with a particular RTTP subject that contains a condition (on the given subjects fields) that when met will trigger a notification message.
    Interface that should be implemented to receive trigger change callbacks from the TriggerProvider
    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.
    Enumeration that defines the different states a Trigger can be in