internal async Task SendConnectHandShake(
            Uri uri,
            CancellationToken ct,
            string?origin = null,
            IDictionary <string, string>?headers = null,
            IEnumerable <string>?subprotocol     = null)
        {
            var handShakeBytes = ClientHandShake.Compose(uri, origin, headers, subprotocol);

            try
            {
                await _writeFunc(_tcpConnectionService.ConnectionStream, handShakeBytes, ct);
            }
            catch (Exception ex)
            {
                _connectionStatusAction(
                    ConnectionStatus.Aborted,
                    new WebsocketClientLiteException("Unable to complete handshake", ex.InnerException));
            }
        }
        private async Task SendConnectHandShakeAsync(
            Uri uri,
            bool secure,
            string origin = null,
            IDictionary <string, string> headers = null,
            IEnumerable <string> subprotocols    = null)
        {
            var handShake = ClientHandShake.Compose(uri, secure, origin, headers, subprotocols);

            try
            {
                await TcpSocketClient.WriteStream.WriteAsync(handShake, 0, handShake.Length);

                await TcpSocketClient.WriteStream.FlushAsync();
            }
            catch (Exception ex)
            {
                _subjectConnectionStatus.OnNext(ConnectionStatus.Aborted);
                throw new WebsocketClientLiteException("Unable to complete handshake", ex.InnerException);
            }
        }