Exemplo n.º 1
0
        private static void SendServerHandshake(ServerHandshake handshake, Context context)
        {
            // generate a byte array representation of the handshake including the answer to the challenge
            byte[] handshakeBytes = Encoding.UTF8.GetBytes(handshake.ToString());
            Array.Copy(handshake.AnswerBytes, 0, handshakeBytes, handshakeBytes.Length - 16, 16);

            context.UserContext.Send(handshakeBytes, true);
        }
        private static void SendServerHandshake(ServerHandshake handshake, Context context)
        {
            // generate a byte array representation of the handshake including the answer to the challenge
            byte[] handshakeBytes = Encoding.UTF8.GetBytes(handshake.ToString());
            Array.Copy(handshake.AnswerBytes, 0, handshakeBytes, handshakeBytes.Length - 16, 16);

            context.UserContext.Send(handshakeBytes, true);
        }
Exemplo n.º 3
0
        private static ServerHandshake GenerateResponseHandshake(ClientHandshake handshake, WebSocketServer server)
        {
            var responseHandshake = new ServerHandshake()
            {
                Location         = "ws://" + handshake.Host + handshake.ResourcePath,
                Origin           = handshake.Origin,
                AnswerBytes      = GenerateAnswerBytes(handshake.Key1, handshake.Key2, handshake.ChallengeBytes),
                Server           = server,
                RequestProtocols = server.SubProtocols
            };

            return(responseHandshake);
        }
        private static ServerHandshake GenerateResponseHandshake(ClientHandshake handshake, WebSocketServer server)
        {
            var responseHandshake = new ServerHandshake()
            {
                Location = "ws://" + handshake.Host + handshake.ResourcePath,
                Origin = handshake.Origin,
                AnswerBytes = GenerateAnswerBytes(handshake.Key1, handshake.Key2, handshake.ChallengeBytes),
                Server = server,
                RequestProtocols = server.SubProtocols
            };

            return responseHandshake;
        }
Exemplo n.º 5
0
        private static ServerHandshake GenerateResponseHandshake(ClientHandshake handshake, WebSocketServer server)
        {
            // mjb
            string Protocol = "ws://";

            if (server.IsSecure == true)
            {
                Protocol = "wss://";
            }

            var responseHandshake = new ServerHandshake()
            {
                // mjb Location = "ws://" + handshake.Host + handshake.ResourcePath,
                Location = Protocol + handshake.Host + handshake.ResourcePath,

                Origin = handshake.Origin,
                AnswerBytes = GenerateAnswerBytes(handshake.Key1, handshake.Key2, handshake.ChallengeBytes),
                Server = server,
                RequestProtocols = server.SubProtocols
            };

            return responseHandshake;
        }