Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 2
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);
                }
            }
        }