public void VerifyS2CResponse(WebSocketHeaders aHeaders) { if (!aHeaders.GetFirstLineResponse.Equals("HTTP/1.1 101 Switching Protocols")) { throw new WebSocketException("connection failed: missing header field in server handshake: HTTP/1.1"); } if (!aHeaders.GetResponseField(WebSocketConstants.UPGRADE).Equals("websocket")) { throw new WebSocketException("connection failed: missing header field in server handshake: Upgrade"); } if (!aHeaders.GetResponseField(WebSocketConstants.CONNECTION).Equals("Upgrade")) { throw new WebSocketException("connection failed: missing header field in server handshake: Connection"); } if (!aHeaders.GetResponseField(WebSocketConstants.SEC_WEBSOCKET_ACCEPT).Equals(mHybiKeyAccept)) { throw new WebSocketException("connection failed: missing header field in server handshake: Sec-WebSocket-Key"); } if (!aHeaders.GetResponseField(WebSocketConstants.SEC_WEBSOCKET_PROTOCOL).Equals(mProtocol)) { throw new WebSocketException("connection failed: missing header field in server handshake: Sec-WebSocket-Protocol"); } }
public static void CallWithTimeout(Action<WebSocketHeaders> aAction, int aTimeoutMilliseconds, WebSocketHeaders lHeaders) { Thread lThreadToKill = null; Action lWrappedAction = () => { lThreadToKill = Thread.CurrentThread; aAction(lHeaders); }; IAsyncResult lResult = lWrappedAction.BeginInvoke(null, null); if (lResult.AsyncWaitHandle.WaitOne(aTimeoutMilliseconds)) { lWrappedAction.EndInvoke(lResult); } else { lThreadToKill.Abort(); throw new TimeoutException("Timeout"); } }
public static void CallWithTimeout(Action <WebSocketHeaders> aAction, int aTimeoutMilliseconds, WebSocketHeaders lHeaders) { Thread lThreadToKill = null; Action lWrappedAction = () => { lThreadToKill = Thread.CurrentThread; aAction(lHeaders); }; IAsyncResult lResult = lWrappedAction.BeginInvoke(null, null); if (lResult.AsyncWaitHandle.WaitOne(aTimeoutMilliseconds)) { lWrappedAction.EndInvoke(lResult); } else { lThreadToKill.Abort(); throw new TimeoutException("Timeout"); } }