示例#1
0
        public static IHandler BuildHandler(
            WebSocketHttpRequest request,
            Action <string> onMessage,
            Action onClose,
            Action <byte[]> onBinary,
            Action <byte[]> onPing,
            Action <byte[]> onPong)
        {
            var version = GetVersion(request);

            switch (version)
            {
            case "76":
                return(Draft76Handler.Create(request, onMessage));

            case "7":
            case "8":
            case "13":
                return(Hybi13Handler.Create(request, onMessage, onClose, onBinary, onPing, onPong));

            case "policy-file-request":
                return(FlashSocketPolicyRequestHandler.Create(request));
            }

            throw new WebSocketException(WebSocketStatusCodes.UnsupportedDataType);
        }
示例#2
0
        public void Setup()
        {
            _request   = new WebSocketHttpRequest();
            _onClose   = delegate { };
            _onMessage = delegate { };

            _handler = Hybi13Handler.Create(_request, s => _onMessage(s), () => _onClose());
        }
示例#3
0
        public static IHandler BuildHandler(WebSocketHttpRequest request, Action <string> onMessage, Fleck2Extensions.Action onClose, Action <byte[]> onBinary)
        {
            var version = GetVersion(request);

            switch (version)
            {
            case "76":
                return(Draft76Handler.Create(request, onMessage));

            case "7":
            case "8":
            case "13":
                return(Hybi13Handler.Create(request, onMessage, onClose, onBinary));
            }

            throw new WebSocketException(WebSocketStatusCodes.UnsupportedDataType);
        }
示例#4
0
        public static IHandler BuildHandler(WebSocketHttpRequest request, Action <string> onMessage, Action onClose)
        {
            var version = GetVersion(request);

            switch (version)
            {
            case "76":
                return(Draft76Handler.Create(request, onMessage));

            case "7":
                return(Hybi13Handler.Create(request, onMessage, onClose));

            case "8":
                return(Hybi13Handler.Create(request, onMessage, onClose));

            case "13":
                return(Hybi13Handler.Create(request, onMessage, onClose));
            }

            throw new WebSocketException("Unsupported Request");
        }