private void OnWebSocket(WebSocketContext Context) { Verify(Context, (Exception) => { if (Exception == null) { Handshake(EngineIOHttpManager.GetTransport(Context.QueryString), Context); } else { Context.WebSocket.Close(CloseStatusCode.Abnormal, Exception.Message); } }); }
private void OnHttpRequest(object sender, HttpRequestEventArgs e) { Verify(e.Request, (Exception) => { if (Exception == null) { string SID = EngineIOHttpManager.GetSID(e.Request.QueryString); if (_Clients.TryGetValue(SID, out EngineIOSocket Client)) { Client.Transport.OnRequest(e.Request, e.Response); } else { Handshake(EngineIOHttpManager.GetTransport(e.Request.QueryString), e.Request, e.Response); } } else { EngineIOHttpManager.SendErrorMessage(e.Request, e.Response, Exception); } }); }
private EngineIOException Verify(NameValueCollection QueryString, NameValueCollection Headers, EngineIOTransportType ExpectedTransportType) { EngineIOException Exception = Exceptions.UNKNOWN_TRANSPORT; if (EngineIOHttpManager.GetTransport(QueryString).Equals(ExpectedTransportType.ToString())) { bool IsPolling = EngineIOHttpManager.IsPolling(QueryString) && Option.Polling; bool IsWebSocket = EngineIOHttpManager.IsWebSocket(QueryString) && Option.WebSocket; if (IsPolling || IsWebSocket) { if (EngineIOHttpManager.IsValidHeader(EngineIOHttpManager.GetOrigin(Headers))) { Exception = null; } else { Exception = Exceptions.BAD_REQUEST; } } } return(Exception); }