コード例 #1
0
ファイル: Server.cs プロジェクト: TorresLabs/MonoSync
        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);
            }
        }
コード例 #2
0
        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);
            }
        }