コード例 #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);
        }
コード例 #2
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);
        }
コード例 #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);
        }
コード例 #4
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;
        }
コード例 #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;
        }