public async void StartListening() { while (true) { TcpClient tcpClient = await _tcpListener.AcceptTcpClientAsync(); int playerId = ++_playerCounter; Map.Players.Add(playerId, new Player(Utils.RandomColor())); var client = new ServerSideClient(tcpClient, playerId, pos => Map.Players[playerId].TargetPosition = pos); client.BeginReceiving(); client.Disconnected += ClientDisconnected; _newClients.Add(client); } }
public async void StartListening() { while (true) { TcpClient tcpClient = await _tcpListener.AcceptTcpClientAsync(); var player = new Player(Utils.RandomColor()); Map.Players.Add(player); var client = new ServerSideClient(tcpClient, player); client.BeginReceiving(); client.Disconnected += ClientDisconnected; _newClients.Add(client); } }