IncreaseSessionCount() public static method

public static IncreaseSessionCount ( Protocol protocol ) : void
protocol Protocol
return void
Exemplo n.º 1
0
        public async Task RunAsync()
        {
            _listener.Start();

            while (true)
            {
                TcpClient tcpClient = null;

                try
                {
                    tcpClient = await _listener.AcceptTcpClientAsync();
                }
                catch (ObjectDisposedException)
                {
                    // When TcpListener is stopped, outstanding calls to AcceptTcpClientAsync
                    // will throw an ObjectDisposedException. When this happens, it's time to
                    // exit.
                    return;
                }


                var connection = new Connection(tcpClient, _cancellationTokenSource.Token);

                var session = _sessionFactory();

                var sessionTask = session.HandleConnection(connection);

                SessionManager.IncreaseSessionCount(session.Protocol);

                HandleSessionAsynchronously(sessionTask, connection, session);
            }
        }