Feat: Add addPlayer command on sever side #258
@@ -86,7 +86,8 @@ public class ServerApp {
|
|||||||
SESSION_DISCONNECT_JOB_PERIOD,
|
SESSION_DISCONNECT_JOB_PERIOD,
|
||||||
TimeUnit.SECONDS);
|
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 networkManager = new NetworkManager(port, sessionManager, router);
|
||||||
networkManager.start();
|
networkManager.start();
|
||||||
@@ -95,15 +96,19 @@ public class ServerApp {
|
|||||||
/**
|
/**
|
||||||
* Registers command parsers and handlers.
|
* Registers command parsers and handlers.
|
||||||
*
|
*
|
||||||
* @param parserDispatcher the dispatcher responsible for parsing incoming commands
|
* @param parserDispatcher the dispatcher responsible for parsing incoming
|
||||||
* @param commandRouter the router that dispatches parsed commands to appropriate handlers
|
* commands
|
||||||
* @param responseDispatcher the dispatcher responsible for sending responses back to clients
|
* @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(
|
private static void registerCommands(
|
||||||
CommandParserDispatcher parserDispatcher,
|
CommandParserDispatcher parserDispatcher,
|
||||||
CommandRouter commandRouter,
|
CommandRouter commandRouter,
|
||||||
ResponseDispatcher responseDispatcher,
|
ResponseDispatcher responseDispatcher,
|
||||||
UserRegistry userRegistry) {
|
UserRegistry userRegistry,
|
||||||
|
LobbyManager lobbyManager) {
|
||||||
parserDispatcher.register("PING", new PingParser());
|
parserDispatcher.register("PING", new PingParser());
|
||||||
commandRouter.register(PingRequest.class, new PingHandler(responseDispatcher));
|
commandRouter.register(PingRequest.class, new PingHandler(responseDispatcher));
|
||||||
|
|
||||||
@@ -137,5 +142,14 @@ public class ServerApp {
|
|||||||
parserDispatcher.register("LIST_USERS", new ListUsersParser());
|
parserDispatcher.register("LIST_USERS", new ListUsersParser());
|
||||||
commandRouter.register(
|
commandRouter.register(
|
||||||
ListUsersRequest.class, new ListUsersHandler(responseDispatcher, userRegistry));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user