Add: Register JoinLobby command

This commit is contained in:
Jona Walpert
2026-04-11 19:45:55 +02:00
parent 3badca0a01
commit 15d1ea4edd
@@ -86,7 +86,8 @@ public class ServerApp {
SESSION_DISCONNECT_JOB_PERIOD,
TimeUnit.SECONDS);
registerCommands(dispatcher, router, responseDispatcher, userRegistry);
LobbyManager lobbyManager = new LobbyManager();
registerCommands(dispatcher, router, responseDispatcher, userRegistry, lobbyManager);
NetworkManager networkManager = new NetworkManager(port, sessionManager, router);
networkManager.start();
@@ -95,15 +96,19 @@ public class ServerApp {
/**
* Registers command parsers and handlers.
*
* @param parserDispatcher the dispatcher responsible for parsing incoming commands
* @param commandRouter the router that dispatches parsed commands to appropriate handlers
* @param responseDispatcher the dispatcher responsible for sending responses back to clients
* @param parserDispatcher the dispatcher responsible for parsing incoming
* commands
* @param commandRouter the router that dispatches parsed commands to
* appropriate handlers
* @param responseDispatcher the dispatcher responsible for sending responses
* back to clients
*/
private static void registerCommands(
CommandParserDispatcher parserDispatcher,
CommandRouter commandRouter,
ResponseDispatcher responseDispatcher,
UserRegistry userRegistry) {
UserRegistry userRegistry,
LobbyManager lobbyManager) {
parserDispatcher.register("PING", new PingParser());
commandRouter.register(PingRequest.class, new PingHandler(responseDispatcher));
@@ -137,5 +142,14 @@ public class ServerApp {
parserDispatcher.register("LIST_USERS", new ListUsersParser());
commandRouter.register(
ListUsersRequest.class, new ListUsersHandler(responseDispatcher, userRegistry));
// JOIN_LOBBY registration
parserDispatcher.register(
"JOIN_LOBBY",
new ch.unibas.dmi.dbis.cs108.casono.server.app.commands.lobby.join_lobby.JoinLobbyParser());
commandRouter.register(
ch.unibas.dmi.dbis.cs108.casono.server.app.commands.lobby.join_lobby.JoinLobbyRequest.class,
(ch.unibas.dmi.dbis.cs108.casono.server.network.command.execution.CommandHandler<ch.unibas.dmi.dbis.cs108.casono.server.app.commands.lobby.join_lobby.JoinLobbyRequest>) new ch.unibas.dmi.dbis.cs108.casono.server.app.commands.lobby.join_lobby.JoinLobbyHandler(
responseDispatcher, lobbyManager, userRegistry));
}
}