diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyHandler.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyHandler.java
index 9a2b43b..33ca37e 100644
--- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyHandler.java
+++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyHandler.java
@@ -1,19 +1,37 @@
package ch.unibas.dmi.dbis.cs108.casono.server.app.commands.lobby.join_lobby;
+import ch.unibas.dmi.dbis.cs108.casono.server.app.checks.UserLoggedInCheck;
import ch.unibas.dmi.dbis.cs108.casono.server.domain.lobby.LobbyId;
import ch.unibas.dmi.dbis.cs108.casono.server.domain.lobby.LobbyManager;
import ch.unibas.dmi.dbis.cs108.casono.server.domain.user.User;
import ch.unibas.dmi.dbis.cs108.casono.server.domain.user.UserRegistry;
-import ch.unibas.dmi.dbis.cs108.casono.server.app.checks.UserLoggedInCheck;
import ch.unibas.dmi.dbis.cs108.casono.server.network.command.execution.CommandHandler;
import ch.unibas.dmi.dbis.cs108.casono.server.network.protocol.response.ErrorResponse;
import ch.unibas.dmi.dbis.cs108.casono.server.network.protocol.response.OkResponse;
import ch.unibas.dmi.dbis.cs108.casono.server.network.protocol.response.dispatcher.ResponseDispatcher;
+/**
+ * Handler for the `JOIN_LOBBY` command.
+ *
+ *
+ * Resolves the username from the session (requires {@link UserLoggedInCheck}),
+ * looks up the target lobby and attempts to add the user. On success an
+ * `+OK` response is dispatched; on failure an appropriate {@link ErrorResponse}
+ * with one of the error codes `LOBBY_NOT_FOUND`, `USER_NOT_LOGGED_IN` or
+ * `LOBBY_FULL_OR_ALREADY_IN` is returned.
+ */
public class JoinLobbyHandler extends CommandHandler {
private final LobbyManager lobbyManager;
private final UserRegistry userRegistry;
+ /**
+ * Create a new {@link JoinLobbyHandler}.
+ *
+ * @param responseDispatcher dispatcher used to send responses back to the
+ * client
+ * @param lobbyManager manager providing lobby state and operations
+ * @param userRegistry registry to resolve session -> user mappings
+ */
public JoinLobbyHandler(
ResponseDispatcher responseDispatcher,
LobbyManager lobbyManager,
@@ -24,6 +42,11 @@ public class JoinLobbyHandler extends CommandHandler {
addCheck(new UserLoggedInCheck(userRegistry));
}
+ /**
+ * Execute the join-lobby request.
+ *
+ * @param request the parsed {@link JoinLobbyRequest}
+ */
@Override
public void execute(JoinLobbyRequest request) {
LobbyId lid = LobbyId.of(request.getId());
diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyParser.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyParser.java
index facb1a4..c7cb217 100644
--- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyParser.java
+++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyParser.java
@@ -4,11 +4,29 @@ import ch.unibas.dmi.dbis.cs108.casono.server.network.command.parsing.CommandPar
import ch.unibas.dmi.dbis.cs108.casono.server.network.protocol.request.PrimitiveRequest;
import ch.unibas.dmi.dbis.cs108.casono.server.network.protocol.request.accessor.RequestParameterAccessor;
+/**
+ * Parser for the `JOIN_LOBBY` command.
+ *
+ *
+ * Expected request parameters:
+ *
+ * - `ID` (int) — numeric lobby identifier (required)
+ *
+ *
+ *
+ * The parser builds a {@link JoinLobbyRequest} containing the parsed lobby id
+ * and the original request context.
+ */
public class JoinLobbyParser implements CommandParser {
+ /**
+ * Parse the incoming primitive request into a {@link JoinLobbyRequest}.
+ *
+ * @param primitiveRequest the raw primitive request
+ * @return a {@link JoinLobbyRequest} with the parsed lobby id and context
+ */
@Override
public JoinLobbyRequest parse(PrimitiveRequest primitiveRequest) {
- RequestParameterAccessor accessor =
- new RequestParameterAccessor(primitiveRequest.parameters());
+ RequestParameterAccessor accessor = new RequestParameterAccessor(primitiveRequest.parameters());
int id = accessor.require("ID", Integer::parseInt);
return new JoinLobbyRequest(primitiveRequest.context(), id);
}
diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyRequest.java b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyRequest.java
index 8c455f2..f667a66 100644
--- a/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyRequest.java
+++ b/src/main/java/ch/unibas/dmi/dbis/cs108/casono/server/app/commands/lobby/join_lobby/JoinLobbyRequest.java
@@ -3,14 +3,32 @@ package ch.unibas.dmi.dbis.cs108.casono.server.app.commands.lobby.join_lobby;
import ch.unibas.dmi.dbis.cs108.casono.server.network.protocol.request.Request;
import ch.unibas.dmi.dbis.cs108.casono.server.network.protocol.request.RequestContext;
+/**
+ * Request data for the `JOIN_LOBBY` command.
+ *
+ *
+ * Contains the lobby id the client wants to join and inherits the
+ * {@link Request} contextual information.
+ */
public class JoinLobbyRequest extends Request {
private final int id;
+ /**
+ * Create a new {@link JoinLobbyRequest}.
+ *
+ * @param context the request context
+ * @param id numeric lobby id to join
+ */
public JoinLobbyRequest(RequestContext context, int id) {
super(context);
this.id = id;
}
+ /**
+ * Returns the lobby id requested by the client.
+ *
+ * @return numeric lobby id
+ */
public int getId() {
return id;
}