Exemplo n.º 1
0
 public static IWebSocketHandler Create(WebSocketHttpRequest request, Action <string> onMessage)
 {
     return(new ComposableHandler
     {
         TextFrame = Draft76Handler.FrameText,
         Handshake = sub => Draft76Handler.Handshake(request, sub),
         ReceiveData = data => ReceiveData(onMessage, data)
     });
 }
        public static IWebSocketHandler BuildHandler(WebSocketHttpRequest request, Action <string> onMessage, 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);
        }