/// <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 = this._httpHandler ?? 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>
        /// Processes all ASP.NET requests passing  the context to the HttpRuntime.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        Task ProcessAspNetRequest(IOwinContext context)
        {
            var request = new WisejWorkerRequest(context);

            // process the classic pipeline and return the async task to the owin pipeline.
            try
            {
                var task = request.Task;
                HttpRuntime.ProcessRequest(request);
                return(task);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message + "\r\n" + ex.StackTrace);
                return(Task.FromResult(0));
            }
        }