Package com.caplin.streamlink.alerts

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

See: Description

Package com.caplin.streamlink.alerts Description

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)
                {
                        
                }
        }
}

Please send bug reports and comments to Caplin support