ProcessAsync() public method

public ProcessAsync ( ) : Task
return Task
Esempio n. 1
0
        private async Task AcceptNextClient()
        {
            TcpClient tcpClient = null;

            try
            {
                tcpClient = await _listener.AcceptTcpClientAsync();
            }
            catch (InvalidOperationException)
            {
                if (IsRunning)
                {
                    throw;
                }

                _logger.LogDebug("Got InvalidOperationException on listener, shutting down");
                //normal - caused by _listener.Stop();
            }

            if (IsRunning)
            {
                _logger.LogDebug("New connection from {0}", tcpClient.Client.RemoteEndPoint);

                var connection = new Connection(this, new TcpClientConnectionChannel(tcpClient), GetVerbMap());
                _activeConnections.Add(connection);
                connection.ConnectionClosed += (s, ea) =>
                {
                    _logger.LogDebug("Connection {0} handling completed removing from active connections", connection);
                    _activeConnections.Remove(connection);
                };
#pragma warning disable 4014
                connection.ProcessAsync();
#pragma warning restore 4014
            }
        }
Esempio n. 2
0
        private async Task AcceptNextClient()
        {
            TcpClient tcpClient = null;

            try
            {
                tcpClient = await this.listener.AcceptTcpClientAsync().ConfigureAwait(false);
            }
            catch (SocketException)
            {
                if (this.IsRunning)
                {
                    throw;
                }

                this.logger.LogDebug("Got SocketException on listener, shutting down");

                // normal - caused by _listener.Stop();
            }
            catch (InvalidOperationException)
            {
                if (this.IsRunning)
                {
                    throw;
                }

                this.logger.LogDebug("Got InvalidOperationException on listener, shutting down");

                // normal - caused by _listener.Stop();
            }

            if (this.IsRunning)
            {
                this.logger.LogDebug("New connection from {0}", tcpClient.Client.RemoteEndPoint);

                TcpClientConnectionChannel connectionChannel = new TcpClientConnectionChannel(tcpClient, this.Behaviour.FallbackEncoding);
                connectionChannel.ReceiveTimeout = await this.Behaviour.GetReceiveTimeout(connectionChannel).ConfigureAwait(false);

                connectionChannel.SendTimeout = await this.Behaviour.GetSendTimeout(connectionChannel).ConfigureAwait(false);

                Connection connection = await Connection.Create(this, connectionChannel, this.CreateVerbMap()).ConfigureAwait(false);

                this.activeConnections.Add(connection);
                connection.ConnectionClosedEventHandler += (s, ea) =>
                {
                    this.logger.LogDebug("Connection {0} handling completed removing from active connections", connection);
                    this.activeConnections.Remove(connection);
                    return(Task.CompletedTask);
                };
#pragma warning disable 4014
                connection.ProcessAsync();
#pragma warning restore 4014
            }
        }
Esempio n. 3
0
        private async Task AcceptNextClient()
        {
            TcpClient tcpClient = null;
            try
            {
                tcpClient = await _listener.AcceptTcpClientAsync();
            }
            catch (InvalidOperationException)
            {
                if (IsRunning)
                {
                    throw;
                }

                _logger.LogDebug("Got InvalidOperationException on listener, shutting down");
                //normal - caused by _listener.Stop();
            }

            if (IsRunning)
            {
                _logger.LogDebug("New connection from {0}", tcpClient.Client.RemoteEndPoint);

                Connection connection = new Connection(this, new TcpClientConnectionChannel(tcpClient), GetVerbMap());
                _activeConnections.Add(connection);
                connection.ConnectionClosed += (s, ea) =>
                {
                    _logger.LogDebug("Connection {0} handling completed removing from active connections", connection);
                    _activeConnections.Remove(connection);
                };
#pragma warning disable 4014
                connection.ProcessAsync();
#pragma warning restore 4014
            }
        }