private void Verify(WebSocketContext Context, Action <EngineIOException> Callback) { EngineIOException Return = null; bool AllowWebSocket = false; try { if ((Return = Verify(Context.QueryString, Context.Headers, EngineIOTransportType.websocket)) == null) { string SID = EngineIOHttpManager.GetSID(Context.QueryString); bool Contains = _Clients.ContainsKey(SID); if (!string.IsNullOrEmpty(SID)) { if (Contains && _Clients.TryGetValue(SID, out EngineIOSocket Socket)) { if (Socket.Transport is EngineIOPolling && Option.AllowUpgrade && Option.WebSocket && !(Socket.Upgrading || Socket.Upgraded)) { if (!(Socket.Upgrading || Socket.Upgraded)) { Socket.UpgradeTransport(new EngineIOWebSocket(Context)); AllowWebSocket = true; } else { Return = Exceptions.BAD_REQUEST; } } else { Return = Exceptions.BAD_REQUEST; } } else { Return = Exceptions.UNKNOWN_SID; } } else { if (Option.AllowWebSocket != null) { AllowWebSocket = true; Option.AllowWebSocket(Context, Callback); } } } } catch (Exception Exception) { EngineIOLogger.Error(this, Return = new EngineIOException("Unknown exception", Exception)); } finally { if (!AllowWebSocket) { Callback(Return); } } }