コード例 #1
0
        /// <summary>
        /// When a client requests a connection, process the websockets HTTP request
        /// </summary>
        protected override IClient <Request, Response> CreateClient(object sender, ClientRequestingConnectionEventArgs <byte, byte> args)
        {
            var address = args.Client.Address;

            Logger.WriteLine("WebSockets: client requesting connection (" + address + ")", Logger.Severity.Debug);
            var request = ConnectionRequest.ReadRequest(args);

            if (args.Request.ShouldDeny)
            {
                Logger.WriteLine("WebSockets: client connection denied (" + address + ")", Logger.Severity.Error);
                return(null);
            }
            var clientName = GetClientName(request);

            clientKeys [args.Client] = request.Headers ["sec-websocket-key"].Single();
            return(new RPCClient(clientName, args.Client, shouldEcho));
        }
コード例 #2
0
        /// <summary>
        /// When a client requests a connection, process the websockets HTTP request
        /// </summary>
        protected override IClient <NoMessage, StreamUpdate> CreateClient(object sender, ClientRequestingConnectionEventArgs <byte, byte> args)
        {
            var request = ConnectionRequest.ReadRequest(args);

            if (args.Request.ShouldDeny)
            {
                return(null);
            }
            var guid = GetGuid(request);

            if (guid == Guid.Empty)
            {
                args.Client.Stream.Write(HTTP.Response.CreateBadRequest().ToBytes());
                args.Request.Deny();
                return(null);
            }
            clientKeys [args.Client] = request.Headers ["sec-websocket-key"].Single();
            return(new StreamClient(guid, args.Client));
        }