public WebSocketMessageWriteRfc6455Stream(WebSocketConnectionRfc6455 client, WebSocketMessageType messageType, WebSocketExtensionFlags extensionFlags)
     : this(client, messageType)
 {
     ExtensionFlags.Rsv1 = extensionFlags.Rsv1;
     ExtensionFlags.Rsv2 = extensionFlags.Rsv2;
     ExtensionFlags.Rsv3 = extensionFlags.Rsv3;
 }
        public WebSocketRfc6455(Stream clientStream, WebSocketListenerOptions options, IPEndPoint local, IPEndPoint remote, WebSocketHttpRequest httpRequest, IReadOnlyList<IWebSocketMessageExtensionContext> extensions)
        {
            if (clientStream == null)
                throw new ArgumentNullException("clientStream");

            if (options == null)
                throw new ArgumentNullException("options");

            if (local == null)
                throw new ArgumentNullException("local");

            if (remote == null)
                throw new ArgumentNullException("remote");

            if (extensions == null)
                throw new ArgumentNullException("extensions");

            if (httpRequest == null)
                throw new ArgumentNullException("httpRequest");

            _remoteEndpoint = remote;
            _localEndpoint = local;
            _httpRequest = httpRequest;

            Connection = new WebSocketConnectionRfc6455(clientStream, options);
            _extensions = extensions;
        }
        internal LatencyControlPing(WebSocketConnectionRfc6455 connection, TimeSpan pingTimeout, ArraySegment <Byte> pingBuffer)
        {
            Guard.ParameterCannotBeNull(connection, nameof(connection));

            _pingTimeout = pingTimeout;
            _pingBuffer  = pingBuffer;
            _connection  = connection;
        }
        internal BandwidthSavingPing(WebSocketConnectionRfc6455 connection, TimeSpan pingTimeout, ArraySegment<Byte> pingBuffer)
        {
            Guard.ParameterCannotBeNull(connection, "connection");

            _connection = connection;
            _pingTimeout = pingTimeout;
            _pingBuffer = pingBuffer;
        }
        internal BandwidthSavingPing(WebSocketConnectionRfc6455 connection, TimeSpan pingTimeout, ArraySegment <byte> pingBuffer)
        {
            Guard.ParameterCannotBeNull(connection, nameof(connection));

            _connection  = connection;
            _pingTimeout = pingTimeout;
            _pingBuffer  = pingBuffer;
        }
        internal LatencyControlPing(WebSocketConnectionRfc6455 connection, TimeSpan pingTimeout, ArraySegment<Byte> pingBuffer)
        {
            Guard.ParameterCannotBeNull(connection, "connection");

            _pingTimeout = pingTimeout;
            _pingBuffer = pingBuffer;
            _connection = connection;
        }
        public WebSocketMessageWriteRfc6455Stream(WebSocketConnectionRfc6455 webSocket, WebSocketMessageType messageType)
        {
            Guard.ParameterCannotBeNull(webSocket, nameof(webSocket));

            _internalUsedBufferLength = 0;
            _messageType = messageType;
            _webSocket   = webSocket;
        }
Exemplo n.º 8
0
        internal LatencyControlPing(WebSocketConnectionRfc6455 connection, TimeSpan pingTimeout, ArraySegment<Byte> pingBuffer)
        {
            if (connection == null)
                throw new ArgumentNullException("connection");

            _pingTimeout = pingTimeout;
            _pingBuffer = pingBuffer;
            _connection = connection;
        }
Exemplo n.º 9
0
        internal BandwidthSavingPing(WebSocketConnectionRfc6455 connection, TimeSpan pingTimeout, ArraySegment <Byte> pingBuffer)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            _connection  = connection;
            _pingTimeout = pingTimeout;
            _pingBuffer  = pingBuffer;
        }
        internal LatencyControlPing(WebSocketConnectionRfc6455 connection, TimeSpan pingTimeout, ArraySegment <Byte> pingBuffer)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            _pingTimeout = pingTimeout;
            _pingBuffer  = pingBuffer;
            _connection  = connection;
        }
Exemplo n.º 11
0
            public ManualPing(WebSocketConnectionRfc6455 connection)
            {
                if (connection == null)
                {
                    throw new ArgumentNullException(nameof(connection));
                }

                _pingTimeout = connection.options.PingTimeout < TimeSpan.Zero ? TimeSpan.MaxValue : connection.options.PingTimeout;
                _pingBuffer  = connection.outPingBuffer;
                _connection  = connection;
                _lastPong    = new Stopwatch();
            }
Exemplo n.º 12
0
        public WebSocketMessageReadRfc6455Stream(WebSocketConnectionRfc6455 webSocket)
        {
            Guard.ParameterCannotBeNull(webSocket, nameof(webSocket));

            _webSocket        = webSocket;
            _messageType      = (WebSocketMessageType)_webSocket.CurrentHeader.Flags.Option;
            _flags            = GetExtensionFlags(_webSocket.CurrentHeader.Flags);
            _hasPendingFrames = !_webSocket.CurrentHeader.Flags.FIN;
            if (_webSocket.CurrentHeader.Flags.Option != WebSocketFrameOption.Binary && _webSocket.CurrentHeader.Flags.Option != WebSocketFrameOption.Text)
            {
                throw new WebSocketException("WebSocketMessageReadNetworkStream can only start with a Text or Binary frame, not " + _webSocket.CurrentHeader.Flags.Option.ToString());
            }
        }
        public WebSocketRfc6455(Stream clientStream, WebSocketListenerOptions options, IPEndPoint local, IPEndPoint remote, WebSocketHttpRequest httpRequest, WebSocketHttpResponse httpResponse, IReadOnlyList<IWebSocketMessageExtensionContext> extensions)
            :base(httpRequest, httpResponse)
        {
            Guard.ParameterCannotBeNull(clientStream, "clientStream");
            Guard.ParameterCannotBeNull(options, "options");
            Guard.ParameterCannotBeNull(local, "local");
            Guard.ParameterCannotBeNull(remote, "remote");
            Guard.ParameterCannotBeNull(extensions, "extensions");
            Guard.ParameterCannotBeNull(httpRequest, "httpRequest");

            _remoteEndpoint = remote;
            _localEndpoint = local;

            Connection = new WebSocketConnectionRfc6455(clientStream, options);
            _extensions = extensions;
        }
Exemplo n.º 14
0
        public WebSocketRfc6455(Stream clientStream, WebSocketListenerOptions options, IPEndPoint local, IPEndPoint remote, WebSocketHttpRequest httpRequest, WebSocketHttpResponse httpResponse, IReadOnlyList <IWebSocketMessageExtensionContext> extensions)
            : base(httpRequest, httpResponse)
        {
            Guard.ParameterCannotBeNull(clientStream, "clientStream");
            Guard.ParameterCannotBeNull(options, "options");
            Guard.ParameterCannotBeNull(local, "local");
            Guard.ParameterCannotBeNull(remote, "remote");
            Guard.ParameterCannotBeNull(extensions, "extensions");
            Guard.ParameterCannotBeNull(httpRequest, "httpRequest");

            _remoteEndpoint = remote;
            _localEndpoint  = local;

            Connection  = new WebSocketConnectionRfc6455(clientStream, options);
            _extensions = extensions;
        }
        public WebSocketRfc6455(Stream clientStream, WebSocketListenerOptions options, IPEndPoint local, IPEndPoint remote, WebSocketHttpRequest httpRequest, WebSocketHttpResponse httpResponse, IEnumerable <IWebSocketMessageExtensionContext> extensions)
            : base(httpRequest, httpResponse)
        {
            Guard.ParameterCannotBeNull(clientStream, nameof(clientStream));
            Guard.ParameterCannotBeNull(options, nameof(options));
            Guard.ParameterCannotBeNull(local, nameof(local));
            Guard.ParameterCannotBeNull(remote, nameof(remote));
            Guard.ParameterCannotBeNull(extensions, nameof(extensions));
            Guard.ParameterCannotBeNull(httpRequest, nameof(httpRequest));

            _remoteEndpoint = remote;
            _localEndpoint  = local;

            _connection  = new WebSocketConnectionRfc6455(clientStream, options);
            _extensions  = extensions;
            _subprotocol = httpResponse.WebSocketProtocol;
        }
Exemplo n.º 16
0
            public ManualPing(WebSocketConnectionRfc6455 connection)
            {
                if (connection == null)
                {
                    throw new ArgumentNullException(nameof(connection));
                }

                this.pingTimeout = connection.options.PingTimeout;
                if (this.pingTimeout < TimeSpan.Zero)
                {
                    this.pingTimeout = TimeSpan.MaxValue;
                }

                this.pingBuffer = connection.outPingBuffer;
                this.connection = connection;
                this.NotifyActivity();
            }
Exemplo n.º 17
0
        public WebSocketRfc6455(Stream clientStream, WebSocketListenerOptions options, IPEndPoint local, IPEndPoint remote, WebSocketHttpRequest httpRequest, WebSocketHttpResponse httpResponse, IReadOnlyList <IWebSocketMessageExtensionContext> extensions)
            : base(httpRequest, httpResponse)
        {
            if (clientStream == null)
            {
                throw new ArgumentNullException("clientStream");
            }

            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (local == null)
            {
                throw new ArgumentNullException("local");
            }

            if (remote == null)
            {
                throw new ArgumentNullException("remote");
            }

            if (extensions == null)
            {
                throw new ArgumentNullException("extensions");
            }

            if (httpRequest == null)
            {
                throw new ArgumentNullException("httpRequest");
            }

            _remoteEndpoint = remote;
            _localEndpoint  = local;

            Connection  = new WebSocketConnectionRfc6455(clientStream, options);
            _extensions = extensions;
        }