DataSource.NET
IConnectionListener Interface
NamespacesCaplin.DataSourceIConnectionListener
This interface allows applications to receive events about the state of DataSource.NET's connection to other DataSource peers.

Should you wish to receive this information in your DataSource, then you must define a class that implements this interface and register it with DataSource.NET using the AddConnectionListener() method.

Declaration Syntax
C#Visual BasicVisual C++
public interface IConnectionListener
Public Interface IConnectionListener
public interface class IConnectionListener
Members
All MembersMethods



IconMemberDescription
PeerStatus(IPeerStatusEvent)
Invoked when a DataSource peer changes state.

ServiceStatus(IServiceStatusEvent)
Invoked when a DataService changes state.

Remarks
Once registered, the implementation will be informed of all changes to peer and DataService status.
Thread Safety

The 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.

Examples

The following class is an example implementation of IConnectionListener that logs connection status change events to the logger.

CopyC#
using System;
using System.Diagnostics;
using Caplin.DataSource;

using Caplin.Logging;

namespace DataSourceExamples.ConnectionListener
{
    public class ExampleConnectionListener : IConnectionListener
    {
        private ILogger logger;

        public ExampleConnectionListener(ILogger logger)
        {
            this.logger = logger;
        }

        #region IConnectionListener Members

        public void ServiceStatus(IServiceStatusEvent ev)
        {
            logger.Log(LogLevels.Notify, "Example", string.Format("Service status updated: {0} {1}", ev.ServiceName, ev.Status));
        }

        public void PeerStatus(IPeerStatusEvent ev)
        {
            logger.Log(LogLevels.Notify, "Example", string.Format("Peer status updated: {0} {1}", ev.Peer.Name, ev.Status));
        }
        #endregion
    }
}

Assembly: DataSource.NET (Module: DataSource.NET) Version: 6.2.6.2123 (6.2.6.2123)