StreamLink.NET
IConnectionListener Interface
StreamLink.NETCaplin.StreamLinkIConnectionListener
This interface allows applications to receive events about the state of StreamLink's connection to the Liberator, the state of any data services the Liberator is using, and the state of the DataSources providing the data services. You must define a class that implements this interface and register it with StreamLink using the AddConnectionListener(IConnectionListener) method of IStreamLinkProvider.
Declaration Syntax
C#Visual BasicVisual C++
public interface IConnectionListener
Public Interface IConnectionListener
public interface class IConnectionListener
Members
All MembersMethods



IconMemberDescription
ConnectionStatusUpdated(IConnectionStatusEvent)
Provides information regarding the state of the connection to the Liberator.

ServiceStatusUpdated(IServiceStatusEvent)
Provides information regarding the status of a data service.

SourceStatusUpdated(ISourceStatusEvent)
Provides information regarding the status of a DataSource connected to the Liberator.

Remarks
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()
        {
            StreamLink 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
        }
    }
}
Thread Safety

IConnectionListener methods are not called on a dedicated worker thread. Therefore, if any of these methods are likely take a relatively long time to execute, they should be coded to run in a separate thread.

Assembly: Caplin.StreamLink (Module: Caplin.StreamLink) Version: 5.0.5.0 (5.0.5.0)