示例#1
0
        private static async Task UpgradeToWebSockets(RavenDBOptions options, IOwinContext context, Func <Task> next)
        {
            var accept = context.Get <Action <IDictionary <string, object>, Func <IDictionary <string, object>, Task> > >("websocket.Accept");

            if (accept == null)
            {
                // Not a websocket request
                await next();

                return;
            }

            WebSocketsTransport webSocketsTrasport = WebSocketTransportFactory.CreateWebSocketTransport(options, context);

            if (webSocketsTrasport != null)
            {
                if (await webSocketsTrasport.TrySetupRequest())
                {
                    accept(new Dictionary <string, object>()
                    {
                        { "websocket.ReceiveBufferSize", 256 },
                        { "websocket.Buffer", webSocketsTrasport.PreAllocatedBuffer },
                        { "websocket.KeepAliveInterval", WebSocket.DefaultKeepAliveInterval }
                    }, webSocketsTrasport.Run);
                }
            }
        }
示例#2
0
        private static async Task UpgradeToWebSockets(RavenDBOptions options, IOwinContext context, Func <Task> next)
        {
            if (context.Request.Uri.LocalPath.EndsWith("changes/websocket") == false)
            {
                // Not a websocket request
                await next();

                return;
            }

            var accept = context.Get <Action <IDictionary <string, object>, Func <IDictionary <string, object>, Task> > >("websocket.Accept");

            if (accept == null)
            {
                // Not a websocket request
                await next();

                return;
            }

            var webSocketsTrasport = new WebSocketsTransport(options, context);

            if (await webSocketsTrasport.TrySetupRequest())
            {
                accept(null, webSocketsTrasport.Run);
            }
        }
示例#3
0
        private static async Task UpgradeToWebSockets(RavenDBOptions options, IOwinContext context, Func <Task> next)
        {
            var accept = context.Get <Action <IDictionary <string, object>, Func <IDictionary <string, object>, Task> > >("websocket.Accept");

            if (accept == null)
            {
                // Not a websocket request
                await next();

                return;
            }

            WebSocketsTransport webSocketsTrasport = WebSocketTransportFactory.CreateWebSocketTransport(options, context);

            if (webSocketsTrasport != null)
            {
                if (await webSocketsTrasport.TrySetupRequest())
                {
                    accept(null, webSocketsTrasport.Run);
                }
            }
        }