Пример #1
0
        private async Task Reconnect()
        {
            if (!_restoreConnection)
            {
                return;
            }

            _connection = null;

            Connect();
            await RestoreSubscriptions();
        }
Пример #2
0
        public async Task Disconnect()
        {
            if (_connection == null)
            {
                return;
            }

            _restoreConnection = false;

            await CloseSubscriptions();

            _connection.Dispose();
            _connection = null;
        }
Пример #3
0
        public void Connect()
        {
            if (_connection != null)
            {
                return;
            }

            var exchangeConnectionSettings = _configurationService.GetExchangeConnectionSettings();

            _connection = ConnectionFactory.GetConnection(exchangeConnectionSettings.ApiKey);
            _connection.StreamingClosed += async(o, e) => await Reconnect();

            _connection.WebSocketException += async(o, e) => await Reconnect();
        }