示例#1
0
        protected override void OnDisconnected()
        {
            // Receive HTTP request body
            if (!NetworkRequest.IsPendingBody())
            {
                return;
            }

            OnReceivedRequestInternal(NetworkRequest);
            NetworkRequest.Clear();
        }
        protected override void OnDisconnected()
        {
            // Disconnect WebSocket
            if (webSocketNetwork.WsHandshaked)
            {
                webSocketNetwork.WsHandshaked = false;
                OnWsDisconnected();
            }

            // Reset WebSocket upgrade HTTP request and response
            NetworkRequest.Clear();
            NetworkResponse.Clear();

            // Clear WebSocket send/receive buffers
            webSocketNetwork.ClearWsBuffers();
        }
示例#3
0
        protected override void OnReceived(Byte[] buffer, Int64 offset, Int64 size)
        {
            // Receive HTTP request header
            if (NetworkRequest.IsPendingHeader())
            {
                if (NetworkRequest.ReceiveHeader(buffer, (Int32)offset, (Int32)size))
                {
                    OnReceivedRequestHeader(NetworkRequest);
                }

                size = 0;
            }

            // Check for HTTP request error
            if (NetworkRequest.IsErrorSet)
            {
                OnReceivedRequestError(NetworkRequest, "Invalid HTTP request!");
                NetworkRequest.Clear();
                Disconnect();
                return;
            }

            // Receive HTTP request body
            if (NetworkRequest.ReceiveBody(buffer, (Int32)offset, (Int32)size))
            {
                OnReceivedRequestInternal(NetworkRequest);
                NetworkRequest.Clear();
                return;
            }

            // Check for HTTP request error
            if (!NetworkRequest.IsErrorSet)
            {
                return;
            }

            OnReceivedRequestError(NetworkRequest, "Invalid HTTP request!");
            NetworkRequest.Clear();
            Disconnect();
        }
 private void SetPromiseError(String error)
 {
     _tcs.SetException(new Exception(error));
     NetworkRequest.Clear();
 }
 private void SetPromiseValue(HttpNetworkResponse response)
 {
     NetworkResponse = new HttpNetworkResponse();
     _tcs.SetResult(response);
     NetworkRequest.Clear();
 }