Class BaseSubscriptionListener
- java.lang.Object
-
- com.caplin.streamlink.BaseSubscriptionListener
-
- All Implemented Interfaces:
SubscriptionListener
public class BaseSubscriptionListener extends java.lang.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 Summary
Constructors Constructor Description BaseSubscriptionListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onChatUpdate(Subscription subscription, ChatEvent event)
Called when a chat update is received.void
onContainerUpdate(Subscription subscription, ContainerEvent event)
Called when a container update is received.void
onDirectoryUpdate(Subscription subscription, DirectoryEvent event)
Called when a directory update is received.void
onJsonUpdate(Subscription subscription, JsonEvent evt)
Called when a json update is received.void
onNewsUpdate(Subscription subscription, NewsEvent event)
Called when a news headline update is received.void
onPageUpdate(Subscription argsubscription0, PageEvent event)
Called when a page update is received.void
onPermissionUpdate(Subscription subscription, PermissionEvent event)
Called when a permission update is received.void
onRecordType2Update(Subscription subscription, RecordType2Event event)
Called when an update to type 2 data in a record is received.void
onRecordType3Update(Subscription subscription, RecordType3Event event)
Called when an update to type 3 data in a record is received.void
onRecordUpdate(Subscription subscription, RecordType1Event event)
Called when an update to type 1 data in a record is received.void
onStoryUpdate(Subscription subscription, StoryEvent event)
Called when a news story update is received.void
onSubscriptionError(Subscription subscription, SubscriptionErrorEvent event)
Called when there is an error in a subscription.void
onSubscriptionStatus(Subscription subscription, SubscriptionStatusEvent event)
Called when there is a change in the status of a subscription.
-
-
-
Method Detail
-
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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- 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 interfaceSubscriptionListener
- Parameters:
subscription
- The subscription for which the update occurred.evt
- The JSON update.
-
-