Feat): Add STATUS param to GET_LOBBY_STATUS and client parsing
This commit is contained in:
@@ -32,7 +32,25 @@ public class LobbyClient {
|
||||
* @return A string representing the current status of the lobby, as returned by the server.
|
||||
*/
|
||||
public String fetchLobbyStatusString(int lobbyId) {
|
||||
return client.processCommand("GET_LOBBY_STATUS ID=" + lobbyId).getFirst();
|
||||
List<String> lines = client.processCommand("GET_LOBBY_STATUS ID=" + lobbyId);
|
||||
|
||||
// Prefer an explicit STATUS parameter if provided by the server
|
||||
List<RequestParameter> params = ClientService.convertToRequestParameters(lines);
|
||||
for (RequestParameter p : params) {
|
||||
if ("STATUS".equalsIgnoreCase(p.key())) {
|
||||
return p.value();
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: look for plain status tokens in the body
|
||||
for (String l : lines) {
|
||||
String t = l.trim();
|
||||
if ("CREATED".equalsIgnoreCase(t) || "RUNNING".equalsIgnoreCase(t)) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
@@ -26,6 +26,13 @@ public class GetLobbyStatusResponse extends SuccessResponse {
|
||||
"LOBBY",
|
||||
lb -> {
|
||||
lb.param("ID", lobby.getId().value());
|
||||
// STATUS indicates whether a game has been started in this
|
||||
// lobby
|
||||
lb.param(
|
||||
"STATUS",
|
||||
lobby.getGameController() == null
|
||||
? "CREATED"
|
||||
: "RUNNING");
|
||||
lb.param("NAME", lobby.getName());
|
||||
lb.block(
|
||||
"PLAYERS",
|
||||
|
||||
Reference in New Issue
Block a user