Adds an IConnectionListener that receives status events
about the state of StreamLink's connection to the server.
Declaration Syntax
C# | Visual Basic | Visual C++ |
void AddConnectionListener( IConnectionListener listener )
Sub AddConnectionListener ( _ listener As IConnectionListener _ )
void AddConnectionListener( IConnectionListener^ listener )
Parameters
- listener (IConnectionListener)
- The IConnectionListener to be registered with the IStreamLinkProvider.
Remarks
Once registered, the IConnectionListener will receive event updates whenever the connection status has changed (for details see the description of IConnectionListener).
You can register more than one IConnectionListener with an IStreamLinkProvider.
Examples
CopyC#
using System; using System.Collections.Generic; using System.Text; using Caplin.StreamLink; using Caplin.StreamLink.Authentication; namespace StreamLinkExamples.Basics { /// <summary> /// Example of an internal class that implements IConnectionListener /// and of how to use the IConnectionListener class. /// </summary> public class AddingAConnectionListener { /// <summary> /// Shows how to create a StreamLink and a connection listener /// and add the listener for connection events. /// </summary> public static void AddingAConnectionListenerExample() { IStreamLink myStreamLink = new StreamLink(); myStreamLink.CredentialsProvider = new PasswordCredentialsProvider("admin", "admin"); IConnectionListener connectionListener = new ExampleConnectionListener(); // Add the new connection listener instance so that it // receives connection related events. myStreamLink.StreamLinkProvider.AddConnectionListener( connectionListener); } /// <summary> /// Example of a class the implements the IConnectionListener. /// </summary> private class ExampleConnectionListener : IConnectionListener { #region IConnectionListener Members // Just log the status update public void ConnectionStatusUpdated(IConnectionStatusEvent ev) { Console.WriteLine("Connection Status Updated: " + ev.Status.ToString()); } // Just log the source update public void SourceStatusUpdated(ISourceStatusEvent ev) { Console.WriteLine( string.Format("Source Status Updated: {0} {1}", ev.Name, ev.Status.ToString())); } // Just log the service update public void ServiceStatusUpdated(IServiceStatusEvent ev) { Console.WriteLine( string.Format("Service Status Updated: {0} {1}", ev.Name, ev.Status.ToString())); } #endregion } } }