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); } } }
public ClientHandler(TcpClient client,int id,GameHandler game) { Client = client; _game = game; FugamId = new FugamID(Client.GetHashCode(),id); _clientThread = new Thread(new ThreadStart(ClientThread)); ServerIO.Send(Client.GetStream(),new PacketFugamID(FugamId)); }