private async Task WaitForIncomingConnectionsAsync()
        {
            while (_listenerStarted)
            {
                try
                {
                    await MaxConnectionsSemaphore.WaitAsync();

                    var client = await _tcpListener.AcceptTcpClientAsync();

                    var communicationChannel = new CommunicationChannel(client);
                    var player             = new Player(communicationChannel);
                    var listenCommandsTask = player.ListenCommandsAsync(this);
                    var x = _activeTasks.TryAdd(listenCommandsTask.Id, listenCommandsTask);
                }
                catch (InvalidOperationException)
                {
                    return;
                }
            }
        }
Esempio n. 2
0
 public Player(CommunicationChannel channel)
 {
     Channel = channel;
 }