Example #1
0
        async Task ProcessHttp(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested && _tcpServer.IsRunning)
            {
                var client = await _tcpServer.Accept();

                if (null != client)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        client.Close(); return;
                    }
                    if (null != _httpHandler)
                    {
                        _ = Task.Run(async() =>
                        {
                            await _httpHandler.HandleHttp(client, this._cancellationStop.Token);
                        }, this._cancellationStop.Token);
                    }
                }
                else
                {
                    _logger?.LogInformation("ProcessTcp null = client");
                    break;
                }
            }//end while
        }