diff --git a/src/game-service/Game.Application/GameApplication.cs b/src/game-service/Game.Application/GameApplication.cs index 8c6139125..6dd173ea4 100644 --- a/src/game-service/Game.Application/GameApplication.cs +++ b/src/game-service/Game.Application/GameApplication.cs @@ -15,6 +15,7 @@ var fleckLog = Env.GetString("FLECK_LOG"); var imLog = Env.GetString("IM_LOG"); var gameLog = Env.GetString("GAME_LOG"); +var maxConnections = Env.GetInt("MAX_CONNECTIONS"); FleckLog.LogAction = FleckLogAction.LogAction; FleckLog.Level = (LogLevel)Enum.Parse(typeof(LogLevel), fleckLog); @@ -26,7 +27,7 @@ var serverComponents = new ComponentCollection(new IComponent[] { new IdGenerator(), - new GameClientCollection(), + new GameClientCollection(maxConnections), new GameSceneCollection(), new GameSceneManager() }); @@ -48,6 +49,10 @@ connection, gameClientCollection, gameSceneCollection); + if (gameClientCollection.Add(gameClient) == false) + { + connection.Close(); - gameClientCollection.Add(gameClient); + GameLog.Debug($"Client #{id} disconnected because server reached maximum number of clients."); + } }); \ No newline at end of file