コード例 #1
0
ファイル: FugamServer.cs プロジェクト: Jannickvb/fugam
        private void ServerStart()
        {
            _server.Start();
            Console.WriteLine("Server start: {0}", DateTime.Now);
            Console.WriteLine("Server Hashcode: {0}", this.GetHashCode());

            int currentClients = 0;
            GameHandler game = new GameHandler(this);

            while (true)
            {
                TcpClient client = _server.AcceptTcpClient();
                Console.WriteLine("Client connected: {0}Added to {1} game{2}",client.GetHashCode(),"\n"+game.GetHashCode(),"");

                game.AddPlayer(client,currentClients);
                currentClients++;

                if (currentClients == MaxPlayersEachGame)
                {
                    game.StartGame();
                    currentClients = 0;
                    game = new GameHandler(this);
                }
            }
        }