public Task Invoke(HttpContext httpContext)
        {
            var result = _next(httpContext);

            if (_routesController.Contains(httpContext.Request.Path.Value))
            {
                _webSocketCollection.SendAll(_channel, _controller.GetData());
            }

            return(result);
        }
예제 #2
0
        public async Task Invoke <TDataObject>(HttpContext context, List <TDataObject> initialData)
        {
            await _manager.AddWebSocketHandler(this);

            await _webSocket.SendData(initialData);

            var data = await _webSocket.ReceiveData();

            while (!data.result.CloseStatus.HasValue)
            {
                await _manager.SendAll(_id.Channel, data.GetValue());

                data = await _webSocket.ReceiveData();
            }
            await _webSocket.CloseAsync(data.result.CloseStatus.Value, data.result.CloseStatusDescription, CancellationToken.None);
        }