(lobbiesV3())
Create a new lobby for an application. A lobby object is a wrapper around a room object. With a lobby, you get additional functionality like configuring the visibility of the room, managing the state of a match, and retrieving a list of public lobbies to display to players.
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.CreateLobbyRequest;
import dev.hathora.cloud_sdk.models.operations.CreateLobbyResponse;
import dev.hathora.cloud_sdk.models.operations.CreateLobbySecurity;
import dev.hathora.cloud_sdk.models.shared.CreateLobbyV3Params;
import dev.hathora.cloud_sdk.models.shared.LobbyVisibility;
import dev.hathora.cloud_sdk.models.shared.Region;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.orgId("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39")
.build();
CreateLobbyRequest req = CreateLobbyRequest.builder()
.createLobbyV3Params(CreateLobbyV3Params.builder()
.region(Region.SEATTLE)
.visibility(LobbyVisibility.PRIVATE)
.roomConfig("{\"name\":\"my-room\"}")
.build())
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.roomId("2swovpy1fnunu")
.shortCode("LFG4")
.build();
CreateLobbyResponse res = sdk.lobbiesV3().createLobby()
.request(req)
.security(CreateLobbySecurity.builder()
.playerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build())
.call();
if (res.lobbyV3().isPresent()) {
// handle response
}
}
}
CreateLobbyResponse
Error Type |
Status Code |
Content Type |
models/errors/ApiError |
400, 401, 402, 404, 422, 429, 500 |
application/json |
models/errors/SDKError |
4XX, 5XX |
*/* |
Get details for a lobby.
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.GetLobbyInfoByRoomIdResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.orgId("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39")
.build();
GetLobbyInfoByRoomIdResponse res = sdk.lobbiesV3().getLobbyInfoByRoomId()
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.roomId("2swovpy1fnunu")
.call();
if (res.lobbyV3().isPresent()) {
// handle response
}
}
}
Parameter |
Type |
Required |
Description |
Example |
appId |
Optional<String> |
➖ |
N/A |
app-af469a92-5b45-4565-b3c4-b79878de67d2 |
roomId |
String |
✔️ |
N/A |
2swovpy1fnunu |
GetLobbyInfoByRoomIdResponse
Error Type |
Status Code |
Content Type |
models/errors/ApiError |
404, 422, 429 |
application/json |
models/errors/SDKError |
4XX, 5XX |
*/* |
Get details for a lobby. If 2 or more lobbies have the same shortCode
, then the most recently created lobby will be returned.
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.GetLobbyInfoByShortCodeResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.orgId("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39")
.build();
GetLobbyInfoByShortCodeResponse res = sdk.lobbiesV3().getLobbyInfoByShortCode()
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.shortCode("LFG4")
.call();
if (res.lobbyV3().isPresent()) {
// handle response
}
}
}
Parameter |
Type |
Required |
Description |
Example |
appId |
Optional<String> |
➖ |
N/A |
app-af469a92-5b45-4565-b3c4-b79878de67d2 |
shortCode |
String |
✔️ |
N/A |
LFG4 |
GetLobbyInfoByShortCodeResponse
Error Type |
Status Code |
Content Type |
models/errors/ApiError |
404, 429 |
application/json |
models/errors/SDKError |
4XX, 5XX |
*/* |
Get all active lobbies for a given application. Filter the array by optionally passing in a region
. Use this endpoint to display all public lobbies that a player can join in the game client.
package hello.world;
import dev.hathora.cloud_sdk.HathoraCloud;
import dev.hathora.cloud_sdk.models.errors.ApiError;
import dev.hathora.cloud_sdk.models.operations.ListActivePublicLobbiesResponse;
import dev.hathora.cloud_sdk.models.shared.Region;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ApiError, Exception {
HathoraCloud sdk = HathoraCloud.builder()
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.orgId("org-6f706e83-0ec1-437a-9a46-7d4281eb2f39")
.build();
ListActivePublicLobbiesResponse res = sdk.lobbiesV3().listActivePublicLobbies()
.appId("app-af469a92-5b45-4565-b3c4-b79878de67d2")
.region(Region.LOS_ANGELES)
.call();
if (res.classes().isPresent()) {
// handle response
}
}
}
Parameter |
Type |
Required |
Description |
Example |
appId |
Optional<String> |
➖ |
N/A |
app-af469a92-5b45-4565-b3c4-b79878de67d2 |
region |
Optional<Region> |
➖ |
If omitted, active public lobbies in all regions will be returned. |
|
ListActivePublicLobbiesResponse
Error Type |
Status Code |
Content Type |
models/errors/ApiError |
401, 429 |
application/json |
models/errors/SDKError |
4XX, 5XX |
*/* |