Esempio n. 1
0
        /// <summary>
        /// DSLinkContainer constructor.
        /// </summary>
        /// <param name="config">Configuration for the DSLink</param>
        public DSLinkContainer(Configuration config) : base(config)
        {
            CreateLogger("DSLink");

            Reconnect = true;
            Connector = ConnectorManager.Create(this);

            // Events
            Connector.OnMessage       += OnTextMessage;
            Connector.OnBinaryMessage += OnBinaryMessage;
            Connector.OnWrite         += OnWrite;
            Connector.OnBinaryWrite   += OnBinaryWrite;
            Connector.OnOpen          += OnOpen;
            Connector.OnClose         += OnClose;

            // Overridable events for DSLink writers
            Connector.OnOpen  += OnConnectionOpen;
            Connector.OnClose += OnConnectionClosed;

            _pingTask = Task.Factory.StartNew(OnPingElapsed);
        }