Interface ConnectionListener

All Known Implementing Classes:
BaseConnectionListener

public interface ConnectionListener

Defines the interface for receiving information about changes in the state of the StreamLink connection, the data services available from the Liberator, and the DataSources that are normally connected to the Liberator.

You should implement this interface if your application needs to take particular actions when such state changes occur.

Your application should not call into StreamLink when the connection status changes; StreamLink manages the connection state and will recover the connection to the Liberator without your application intervening.

A trivial implementation would be as follows :

import com.caplin.streamlink.ConnectionListener;
import com.caplin.streamlink.ConnectionStatusEvent;
import com.caplin.streamlink.ServiceStatusEvent;
import com.caplin.streamlink.SourceStatusEvent;
import com.caplin.streamlink.StatisticsEvent;
import com.caplin.streamlink.StreamLink;


public class ConnectionListenerSnippet {
        
        public ConnectionListenerSnippet(StreamLink streamLink) {
                streamLink.addConnectionListener(new ConnectionListener() {
                        
                        public void onStatisticsChange(StatisticsEvent statisticsEvent) {
                                System.out.println("Latency : " + statisticsEvent.getAverageLatency());
                        }
                        
                        public void onSourceStatusChange(SourceStatusEvent sourceStatusEvent) {
                                System.out.println(sourceStatusEvent.getSourceName()
                                + " is now " + sourceStatusEvent.getSourceStatus());
                        }
                        
                        public void onServiceStatusChange(ServiceStatusEvent serviceStatusEvent) {
                                System.out.println(serviceStatusEvent.getServiceName()
                                + " is now " + serviceStatusEvent.getServiceStatus());
                        }
                        
                        public void onConnectionStatusChange(ConnectionStatusEvent connectionStatusEvent) {
                                System.out.println("Connection State : "
                                + connectionStatusEvent.getConnectionState());
                        }
                        
                });
        }
        
}

  • Method Details

    • onSourceStatusChange

      void onSourceStatusChange(SourceStatusEvent sourceStatusEvent)

      Invoked when the state of one of the Integration Adapters connected to Liberator changes. Implementing this method is optional.

      Parameters:
      sourceStatusEvent - The new status of the Integration Adapter.
    • onConnectionStatusChange

      void onConnectionStatusChange(ConnectionStatusEvent connectionStatusEvent)

      Invoked when the state of the StreamLink connection changes. Implementing this method is optional.

      Parameters:
      connectionStatusEvent - The new status of the connection.
    • onServiceStatusChange

      void onServiceStatusChange(ServiceStatusEvent serviceStatusEvent)

      Invoked when the state of a data service available from the Liberator changes. Implementing this method is optional.

      Parameters:
      serviceStatusEvent - The new status of the data service.
    • onStatisticsChange

      void onStatisticsChange(StatisticsEvent statisticsEvent)

      Invoked when new connection statistics are available. Implementing this method is optional.

      Parameters:
      statisticsEvent - The new connection statistics.