Exemplo n.º 1
0
        public DSLinkContainer(Configuration config)
        {
            _config = config;
            _config._processOptions();
            _logger             = new ConsoleLogger("DSLink", config.LogLevel);
            _logger             = (BaseLogger)Activator.CreateInstance(_config.LoggerType, "DSLink", _config.LogLevel);
            _reconnectOnFailure = true;
            _connector          = new WebSocketConnector(_config, _logger);

            if (Config.Responder)
            {
                _responder = new DSLinkResponder(this);
                _responder.Init();
            }
            if (Config.Requester)
            {
                _requester = new DSLinkRequester(this);
                _requester.Init();
            }

            // Connector events
            _connector.OnMessage       += OnStringRead;
            _connector.OnBinaryMessage += OnBinaryRead;
            _connector.OnWrite         += OnStringWrite;
            _connector.OnBinaryWrite   += OnBinaryWrite;
            _connector.OnOpen          += OnOpen;
            _connector.OnClose         += OnClose;

            // Overridable events for DSLink writers
            _connector.OnOpen  += OnConnectionOpen;
            _connector.OnClose += OnConnectionClosed;
        }
Exemplo n.º 2
0
        public DSLinkContainer(Configuration config)
        {
            _config = config;

            InitConnector();

            if (Config.Responder)
            {
                _responder = new DSLinkResponder(this);
                _responder.Init();
            }

            if (Config.Requester)
            {
                _requester = new DSLinkRequester(this);
                _requester.Init();
            }
        }