Class BaseSubscriptionListener

java.lang.Object
com.caplin.streamlink.BaseSubscriptionListener
All Implemented Interfaces:
SubscriptionListener

public class BaseSubscriptionListener extends Object implements SubscriptionListener

Adapter class implementing the SubscriptionListener methods

This is a helper class to reduce the code needed to implement the SubscriptionListener interface.

Simply extend this class and override the required methods rather than implement the full SubscriptionListener interface.

A trivial implementation would be as follows :

import com.caplin.streamlink.BaseSubscriptionListener;
import com.caplin.streamlink.NewsEvent;
import com.caplin.streamlink.RecordType1Event;
import com.caplin.streamlink.Subscription;
import com.caplin.streamlink.SubscriptionErrorEvent;
import com.caplin.streamlink.SubscriptionListener;

public class BaseSubscriptionListenerSnippet
{
        
        public BaseSubscriptionListenerSnippet()
        {
                // Subscribe to the record.
                SubscriptionListener listener = new BaseSubscriptionListener() {
                        
                        // Print error message if there is a subscription error.
                        @Override
                        public void onSubscriptionError(Subscription subscription,
                        SubscriptionErrorEvent event) {
                                
                                System.out.println("Error: Subject " + event.getSubject()
                                + " is " + event.getError());
                        }
                        
                        // Print latest record values.
                        @Override
                        public void onRecordUpdate(Subscription subscription,
                        RecordType1Event event) {
                                
                                System.out.println("Record update for " + event.getSubject() + " fields: "
                                + event.getFields());
                        }
                        
                        @Override
                        public void onNewsUpdate(Subscription subscription,
                        NewsEvent event) {
                                
                                System.out.println("News Event: " + event.getSubject()
                                + " is " + event.getHeadline());
                        }
                };
        }
}

  • Constructor Details

    • BaseSubscriptionListener

      public BaseSubscriptionListener()
  • Method Details

    • onRecordUpdate

      public void onRecordUpdate(Subscription subscription, RecordType1Event event)
      Description copied from interface: SubscriptionListener

      Called when an update to type 1 data in a record is received. Implementing this method is optional.

      Specified by:
      onRecordUpdate in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      event - The record update.
    • onRecordType2Update

      public void onRecordType2Update(Subscription subscription, RecordType2Event event)
      Description copied from interface: SubscriptionListener

      Called when an update to type 2 data in a record is received. Implementing this method is optional.

      Specified by:
      onRecordType2Update in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      event - The record update.
    • onRecordType3Update

      public void onRecordType3Update(Subscription subscription, RecordType3Event event)
      Description copied from interface: SubscriptionListener

      Called when an update to type 3 data in a record is received. Implementing this method is optional.

      Specified by:
      onRecordType3Update in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      event - The record update.
    • onPermissionUpdate

      public void onPermissionUpdate(Subscription subscription, PermissionEvent event)
      Description copied from interface: SubscriptionListener

      Called when a permission update is received. Implementing this method is optional.

      Specified by:
      onPermissionUpdate in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      event - The permission update.
    • onNewsUpdate

      public void onNewsUpdate(Subscription subscription, NewsEvent event)
      Description copied from interface: SubscriptionListener

      Called when a news headline update is received. Implementing this method is optional.

      Specified by:
      onNewsUpdate in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      event - The news headline update.
    • onStoryUpdate

      public void onStoryUpdate(Subscription subscription, StoryEvent event)
      Description copied from interface: SubscriptionListener

      Called when a news story update is received. Implementing this method is optional.

      Specified by:
      onStoryUpdate in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      event - The news story update.
    • onChatUpdate

      public void onChatUpdate(Subscription subscription, ChatEvent event)
      Description copied from interface: SubscriptionListener

      Called when a chat update is received. Implementing this method is optional.

      Specified by:
      onChatUpdate in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      event - The chat update.
    • onDirectoryUpdate

      public void onDirectoryUpdate(Subscription subscription, DirectoryEvent event)
      Description copied from interface: SubscriptionListener

      Called when a directory update is received. Implementing this method is optional.

      Specified by:
      onDirectoryUpdate in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      event - The directory update.
    • onContainerUpdate

      public void onContainerUpdate(Subscription subscription, ContainerEvent event)
      Description copied from interface: SubscriptionListener

      Called when a container update is received. Implementing this method is optional.

      Specified by:
      onContainerUpdate in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      event - The container update.
    • onSubscriptionStatus

      public void onSubscriptionStatus(Subscription subscription, SubscriptionStatusEvent event)
      Description copied from interface: SubscriptionListener

      Called when there is a change in the status of a subscription.

      Specified by:
      onSubscriptionStatus in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      event - The subscription status event.
    • onSubscriptionError

      public void onSubscriptionError(Subscription subscription, SubscriptionErrorEvent event)
      Description copied from interface: SubscriptionListener

      Called when there is an error in a subscription.

      This callback being invoked is a final state for the subscription and no further callbacks will be received for it.

      Specified by:
      onSubscriptionError in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the error occurred.
      event - The subscription error event.
    • onPageUpdate

      public void onPageUpdate(Subscription argsubscription0, PageEvent event)
      Description copied from interface: SubscriptionListener

      Called when a page update is received. Implementing this method is optional.

      Specified by:
      onPageUpdate in interface SubscriptionListener
      Parameters:
      argsubscription0 - The subscription for which the update occurred.
      event - The page update.
    • onJsonUpdate

      public void onJsonUpdate(Subscription subscription, JsonEvent evt)
      Description copied from interface: SubscriptionListener

      Called when a json update is received. Implementing this method is optional.

      Specified by:
      onJsonUpdate in interface SubscriptionListener
      Parameters:
      subscription - The subscription for which the update occurred.
      evt - The JSON update.