Exemple #1
0
        public static WebSocketServerHandshake Handshake(object signal, Socket socket)
        {
            if (signal == null || socket == null)
            {
                return(null);
            }
            WebSocketServerHandshake handshake;

            lock (signal)
            {
                if (!socket.Connected || SocketExtension.CleanedUp(socket))
                {
                    return(null);
                }
                handshake = new WebSocketServerHandshake(signal, socket);
            }
            if (handshake == null || !handshake.Handle())
            {
                return(null);
            }
            return(handshake);
        }
Exemple #2
0
 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);
     }
 }