Exemple #1
0
        public async ValueTask ConnectAsync(Uri url, CancellationToken token)
        {
            ThrowIfDisposed();

            _limboCts?.Cancel();
            _limboCts?.Dispose();
            _limboCts = new Cts();
            _ws?.Dispose();
            _ws = _webSocketClientFactory.CreateClient();
            if (_supportsZLib)
            {
                _receiveZLibStream?.Dispose();
                _receiveZLibStream = _createZLibStream(_receiveStream);
            }
            await _ws.ConnectAsync(url, token).ConfigureAwait(false);
        }
        public async ValueTask ConnectAsync(Uri url, CancellationToken token)
        {
            ThrowIfDisposed();

            _limboCts?.Cancel();
            _limboCts?.Dispose();
            _limboCts = new Cts();
            _ws?.Dispose();
            _ws = _webSocketClientFactory.CreateClient();
            if (_supportsZLib)
            {
                _receiveZLibStream?.Dispose();
                _receiveZLibStream =
#if NET5_0
                    CreateZLibStream(_receiveStream);
#else
                    new ZLibStream(_receiveStream, CompressionMode.Decompress, true);
#endif
            }

            await _ws.ConnectAsync(url, token).ConfigureAwait(false);
        }