Fix: add correct parsing on client side for create_lobyb command
This commit is contained in:
@@ -41,8 +41,25 @@ public class LobbyClient {
|
|||||||
* @return The id of the newly created lobby, as returned by the server.
|
* @return The id of the newly created lobby, as returned by the server.
|
||||||
*/
|
*/
|
||||||
public int createLobby() {
|
public int createLobby() {
|
||||||
String response = client.processCommand("CREATE_LOBBY").getFirst();
|
List<String> lines = client.processCommand("CREATE_LOBBY");
|
||||||
return Integer.parseInt(response);
|
|
||||||
|
List<RequestParameter> params = ClientService.convertToRequestParameters(lines);
|
||||||
|
for (RequestParameter p : params) {
|
||||||
|
if ("LOBBY_ID".equalsIgnoreCase(p.key())) {
|
||||||
|
return Integer.parseInt(p.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback for simple legacy/test servers that return the id as a single plain
|
||||||
|
// line
|
||||||
|
if (!lines.isEmpty()) {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(lines.get(0));
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException("No LOBBY_ID in response: " + lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user