public static WebSocketSessionHandshake Handshake(object signal, Socket socket, Uri uri) { if (signal == null || socket == null || uri == null) { return(null); } WebSocketSessionHandshake handshake; lock (signal) { if (!socket.Connected || SocketExtension.CleanedUp(socket)) { return(null); } handshake = new WebSocketSessionHandshake(signal, socket, uri); } if (handshake == null || !handshake.Handle()) { return(null); } return(handshake); }
private void Handshake() { lock (this) { if (clientMode) { sessionHandshake = WebSocketSessionHandshake.Handshake(this, socket, connectUri); } else { serverHandshake = WebSocketServerHandshake.Handshake(this, socket); } } if (serverHandshake == null && sessionHandshake == null) { CloseOrError(true); } else { DoOpen(EventArgs.Empty); ProcessReceive(null); } }