コード例 #1
0
        public void CreateHandler(IEnumerable <byte> data)
        {
            var request = _parseRequest(data.ToArray());

            if (request == null)
            {
                return;
            }

            Handler = _handlerFactory(request);
            if (Handler == null)
            {
                return;
            }

            var subProtocol = _negotiateSubProtocol(request.SubProtocols);

            ConnectionInfo = WebSocketConnectionInfo.Create(request, Socket.RemoteIpAddress, Socket.RemotePort, subProtocol);

            _initialize(this);

            var handshake = Handler.CreateHandshake(subProtocol);

            Send(handshake, "handshake", OnOpen);
        }
コード例 #2
0
ファイル: WebSocketConnection.cs プロジェクト: mdsitton/Fleck
        public bool CreateHandler(ArraySegment <byte> data)
        {
            var request = _parseRequest(data);

            if (request == null)
            {
                return(false);
            }

            Handler = _handlerFactory(this, request);
            if (Handler == null)
            {
                return(false);
            }

            ConnectionInfo = WebSocketConnectionInfo.Create(request, Socket.RemoteIpAddress, Socket.RemotePort);

            _initialize(this);

            var handshake = Handler.CreateHandshake();

            SendBytes(handshake, (instance, success) =>
            {
                if (success)
                {
                    instance.OnOpen();
                }
            });

            return(true);
        }
コード例 #3
0
        public void CreateHandler(IEnumerable <byte> data)
        {
            var request = _parseRequest(data.ToArray());

            if (request == null)
            {
                return;
            }
            Handler = _handlerFactory(request);
            if (Handler == null)
            {
                return;
            }
            ConnectionInfo = WebSocketConnectionInfo.Create(request, Socket.RemoteIpAddress, Socket.RemotePort);

            _initialize(this);

            var handshake = Handler.CreateHandshake();

            SendBytes(handshake, OnOpen);
        }