Ejemplo n.º 1
0
        /// <summary>
        /// Processes all .wx requests calling the Wisej handler directly.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        Task ProcessWisejRequest(IOwinContext context)
        {
            var request     = new WisejWorkerRequest(context);
            var httpContext = new HttpContext(request);

            HttpContext.Current = httpContext;

            // try to upgrade the connection to WebSocket.
            var task = UpgradeToWebSockets(context);

            if (task != null)
            {
                return(task);
            }

            // process the wisej http request and return the async task
            // pegged to the async wisej handler EndProcessRequest.
            var handler = new Wisej.Core.HttpHandler();
            var async   = handler.BeginProcessRequest(
                httpContext,
                r =>
            {
                // flush any custom filter on HttpResponse.
                FilterOutput(httpContext.Response);

                // complete the response.
                httpContext.Response.End();
            },
                null);

            return(Task.Factory.FromAsync(async, handler.EndProcessRequest));
        }
 /// <summary>
 /// Process all requests.
 /// </summary>
 /// <param name="next"></param>
 public WisejMiddleware(OwinMiddleware next) : base(next)
 {
     this._httpHandler = new Wisej.Core.HttpHandler();
     if (!this._httpHandler.IsReusable)
     {
         this._httpHandler = null;
     }
 }
 private async Task ProcessWisejWebSocketRequest(IDictionary <string, object> environment)
 {
     var handler = new Wisej.Core.HttpHandler();
     var context = new WisejWebSocketContext(environment);
     await handler.ProcessWebSocketRequest(context);
 }