Esempio n. 1
0
        internal async Task HandleRequest(HttpContext context)
        {
            if (!context.WebSockets.IsWebSocketRequest)
            {
                if (_replyChannelDispatcher == null)
                {
                    _replyChannelDispatcher = await _replyChannelDispatcherTask;
                }

                await _replyChannel.HandleRequest(context);
            }
            else
            {
                var openTimeoutToken = new TimeoutHelper(((IDefaultCommunicationTimeouts)_httpSettings).OpenTimeout).GetCancellationToken();
                var webSocketContext = await AcceptWebSocketAsync(context, openTimeoutToken);

                if (webSocketContext == null)
                {
                    return;
                }

                var channel = new ServerWebSocketTransportDuplexSessionChannel(context, webSocketContext, _httpSettings, _serviceDispatcher.BaseAddress, _servicesScopeFactory.CreateScope().ServiceProvider);
                channel.ChannelDispatcher = await _serviceDispatcher.CreateServiceChannelDispatcherAsync(channel);

                await channel.StartReceivingAsync();
            }

            return;
        }
 public SessionOpenNotificationHelper(ServerWebSocketTransportDuplexSessionChannel channel)
 {
     this.channel = channel;
 }