예제 #1
0
        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);
        }
예제 #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);
     }
 }