Exemplo n.º 1
0
        public Task AcceptWebSocketRequest(Func <IWebSocket, Task> callback)
        {
            var accept = _environment.Get <Action <IDictionary <string, object>, WebSocketFunc> >(OwinConstants.WebSocketAccept);

            if (accept == null)
            {
                throw new InvalidOperationException(Resources.Error_NotWebSocketRequest);
            }

            var handler = new OwinWebSocketHandler(callback);

            accept(null, handler.ProcessRequestAsync);
            return(TaskAsyncHelper.Empty);
        }
Exemplo n.º 2
0
        public Task AcceptWebSocketRequest(Func <IWebSocket, Task> callback, Task initTask)
        {
            var accept = _environment.Get <Action <IDictionary <string, object>, WebSocketFunc> >(OwinConstants.WebSocketAccept);

            if (accept == null)
            {
                var response = new ServerResponse(_environment);
                response.StatusCode = 400;
                return(response.End(Resources.Error_NotWebSocketRequest));
            }

            var handler = new OwinWebSocketHandler(callback, initTask);

            accept(null, handler.ProcessRequestAsync);
            return(TaskAsyncHelper.Empty);
        }
Exemplo n.º 3
0
        public Task AcceptWebSocketRequest(Func <IWebSocket, Task> callback)
        {
#if NET45
            var accept = _environment.Get <Action <IDictionary <string, object>, WebSocketFunc> >(OwinConstants.WebSocketAccept);
            if (accept == null)
            {
                return(TaskAsyncHelper.FromError(new InvalidOperationException("Not a web socket request")));
            }

            var options = new Dictionary <string, object>();
            var handler = new OwinWebSocketHandler(callback);
            accept(options, handler.ProcessRequestAsync);
            return(TaskAsyncHelper.Empty);
#else
            throw new NotImplementedException();
#endif
        }
Exemplo n.º 4
0
        public Task AcceptWebSocketRequest(Func<IWebSocket, Task> callback)
        {
            var accept = _environment.Get<Action<IDictionary<string, object>, WebSocketFunc>>(OwinConstants.WebSocketAccept);
            if (accept == null)
            {
                throw new InvalidOperationException(Resources.Error_NotWebSocketRequest);
            }

            var options = new Dictionary<string, object>();
            var handler = new OwinWebSocketHandler(callback);
            accept(options, handler.ProcessRequestAsync);
            return TaskAsyncHelper.Empty;
        }
Exemplo n.º 5
0
        private Task AcceptWebSocketRequest(Func<IWebSocket, Task> callback)
        {
            var accept = _context.Environment.Get<Action<IDictionary<string, object>, WebSocketFunc>>(OwinConstants.WebSocketAccept);

            if (accept == null)
            {
                // Bad Request
                _context.Response.StatusCode = 400;
                return _context.Response.End(Resources.Error_NotWebSocketRequest);
            }

            var handler = new OwinWebSocketHandler(callback, _maxIncomingMessageSize);
            accept(null, handler.ProcessRequest);
            return TaskAsyncHelper.Empty;
        }
Exemplo n.º 6
0
        public Task AcceptWebSocketRequest(Func<IWebSocket, Task> callback)
        {
            #if NET45
            var accept = _environment.Get<Action<IDictionary<string, object>, WebSocketFunc>>(OwinConstants.WebSocketAccept);
            if (accept == null)
            {
                return TaskAsyncHelper.FromError(new InvalidOperationException("Not a web socket request"));
            }

            var options = new Dictionary<string, object>();
            var handler = new OwinWebSocketHandler(callback);
            accept(options, handler.ProcessRequestAsync);
            return TaskAsyncHelper.Empty;
            #else
            throw new NotImplementedException();
            #endif
        }
Exemplo n.º 7
0
        public Task AcceptWebSocketRequest(Func<IWebSocket, Task> callback, Task initTask)
        {
            var accept = _environment.Get<Action<IDictionary<string, object>, WebSocketFunc>>(OwinConstants.WebSocketAccept);
            if (accept == null)
            {
                var response = new ServerResponse(_environment);
                response.StatusCode = 400;
                return response.End(Resources.Error_NotWebSocketRequest);
            }

            var handler = new OwinWebSocketHandler(callback, initTask);
            accept(null, handler.ProcessRequestAsync);
            return TaskAsyncHelper.Empty;
        }