コード例 #1
0
ファイル: AspNetHandler.cs プロジェクト: plurby/SignalR
        public override Task ProcessRequestAsync(HttpContextBase context)
#endif


        {
            var request = new AspNetRequest(context.Request, context.User);
            var response = new AspNetResponse(context);
            var hostContext = new HostContext(request, response);

#if NET45
            // Determine if the client should bother to try a websocket request
            hostContext.Items[HostConstants.SupportsWebSockets] = true;
#endif

            // Set the debugging flag
            hostContext.Items[HostConstants.DebugMode] = context.IsDebuggingEnabled;

            // Set the host shutdown token
            hostContext.Items[HostConstants.ShutdownToken] = AppDomainTokenSource.Token;

            // Stick the context in here so transports or other asp.net specific logic can
            // grab at it.
            hostContext.Items["System.Web.HttpContext"] = context;

            // Initialize the connection
            _connection.Initialize(_resolver);

            return _connection.ProcessRequestAsync(hostContext);
        }
コード例 #2
0
ファイル: AspNetHandler.cs プロジェクト: PradeepReddy/SignalR
        public override Task ProcessRequestAsync(HttpContextBase context)
#endif


        {
            // https://developer.mozilla.org/En/HTTP_Access_Control
            string origin = context.Request.Headers["Origin"];
            if (!String.IsNullOrEmpty(origin))
            {
                context.Response.AddHeader("Access-Control-Allow-Origin", origin);
                context.Response.AddHeader("Access-Control-Allow-Credentials", "true");
            }

            var request = new AspNetRequest(context);
            var response = new AspNetResponse(context);
            var hostContext = new HostContext(request, response);

            // Determine if the client should bother to try a websocket request
            hostContext.Items[HostConstants.SupportsWebSockets] = !String.IsNullOrEmpty(context.Request.ServerVariables[WebSocketVersionServerVariable]);

            // Set the debugging flag
            hostContext.Items[HostConstants.DebugMode] = context.IsDebuggingEnabled;

            // Set the host shutdown token
            hostContext.Items[HostConstants.ShutdownToken] = AppDomainTokenSource.Token;

            // Stick the context in here so transports or other asp.net specific logic can
            // grab at it.
            hostContext.Items["System.Web.HttpContext"] = context;

            // Initialize the connection
            _connection.Initialize(_resolver);

            return _connection.ProcessRequestAsync(hostContext);
        }
コード例 #3
0
        public override Task ProcessRequestAsync(HttpContextBase context)
#endif
        {
            // https://developer.mozilla.org/En/HTTP_Access_Control
            string origin = context.Request.Headers["Origin"];

            if (!String.IsNullOrEmpty(origin))
            {
                context.Response.AddHeader("Access-Control-Allow-Origin", origin);
                context.Response.AddHeader("Access-Control-Allow-Credentials", "true");
            }

            var request     = new AspNetRequest(context);
            var response    = new AspNetResponse(context);
            var hostContext = new HostContext(request, response);

            // Determine if the client should bother to try a websocket request
#if NET45
            hostContext.Items[HostConstants.SupportsWebSockets] = HttpRuntime.IISVersion != null && HttpRuntime.IISVersion.Major >= 8 && !String.IsNullOrEmpty(context.Request.ServerVariables[WebSocketVersionServerVariable]);
#else
            hostContext.Items[HostConstants.SupportsWebSockets] = false;
#endif
            // Set the debugging flag
            hostContext.Items[HostConstants.DebugMode] = context.IsDebuggingEnabled;

            // Set the host shutdown token
            hostContext.Items[HostConstants.ShutdownToken] = AppDomainTokenSource.Token;

            // Stick the context in here so transports or other asp.net specific logic can
            // grab at it.
            hostContext.Items["System.Web.HttpContext"] = context;

            // Initialize the connection
            _connection.Initialize(_resolver);

            try
            {
                return(_connection.ProcessRequestAsync(hostContext));
            }
            catch (NotSupportedException)          // WebSockets not supported
            {
                context.Response.StatusCode = 501; // HTTP 501 Not Implemented
                return(TaskAsyncHelper.Empty);
            }
        }
コード例 #4
0
ファイル: AspNetHandler.cs プロジェクト: nairit/SignalR
        public override Task ProcessRequestAsync(HttpContextBase context)
#endif
        {
            // https://developer.mozilla.org/En/HTTP_Access_Control
            string origin = context.Request.Headers["Origin"];
            if (!String.IsNullOrEmpty(origin))
            {
                context.Response.AddHeader("Access-Control-Allow-Origin", origin);
                context.Response.AddHeader("Access-Control-Allow-Credentials", "true");
            }

            var request = new AspNetRequest(context);
            var response = new AspNetResponse(context);
            var hostContext = new HostContext(request, response);

            // Determine if the client should bother to try a websocket request
#if NET45
            hostContext.Items[HostConstants.SupportsWebSockets] = HttpRuntime.IISVersion != null && HttpRuntime.IISVersion.Major >= 8 && !String.IsNullOrEmpty(context.Request.ServerVariables[WebSocketVersionServerVariable]);
#else
            hostContext.Items[HostConstants.SupportsWebSockets] = false;
#endif
            // Set the debugging flag
            hostContext.Items[HostConstants.DebugMode] = context.IsDebuggingEnabled;

            // Set the host shutdown token
            hostContext.Items[HostConstants.ShutdownToken] = AppDomainTokenSource.Token;

            // Stick the context in here so transports or other asp.net specific logic can
            // grab at it.
            hostContext.Items["System.Web.HttpContext"] = context;

            // Initialize the connection
            _connection.Initialize(_resolver);

            try
            {
                return _connection.ProcessRequestAsync(hostContext);
            }
            catch (NotSupportedException) // WebSockets not supported
            {
                context.Response.StatusCode = 501; // HTTP 501 Not Implemented
                return TaskAsyncHelper.Empty;
            }
        }