WavedashDocs

Multiplayer lobbies

Create and manage multiplayer game lobbies

The Lobbies API lets you create multiplayer rooms where players can gather before or during gameplay. Lobbies support real-time messaging, metadata storage, and automatic P2P connection setup.

Creating a lobby

func _ready():
    WavedashSDK.lobby_created.connect(_on_lobby_created)

func create_lobby():
    WavedashSDK.create_lobby(WavedashConstants.LOBBY_TYPE_PUBLIC, 4)

func _on_lobby_created(response):
    if response.get("success", false):
        print("Created lobby: ", response["data"])

Visibility options

ValueConstantDescription
0PUBLICAnyone can find and join
1FRIENDS_ONLYOnly friends can see and join
2PRIVATEOnly joinable with the lobby ID

Joining, leaving, and listing

WavedashSDK.join_lobby(lobby_id)
WavedashSDK.leave_lobby(lobby_id)
WavedashSDK.list_available_lobbies()

Lobby users

var users = WavedashSDK.get_lobby_users(lobby_id)
var host_id = WavedashSDK.get_lobby_host_id(lobby_id)
var count = WavedashSDK.get_num_lobby_users(lobby_id)

Messaging

WavedashSDK.send_lobby_chat_message(lobby_id, message)

func _ready():
    WavedashSDK.lobby_message.connect(_on_lobby_message)

func _on_lobby_message(payload):
    print(payload["username"], ": ", payload["message"])

Messages have a maximum length of 500 characters.

Invites

WavedashSDK.invite_user_to_lobby(lobby_id, user_id)

func _ready():
    WavedashSDK.lobby_invite.connect(_on_lobby_invite)

func _on_lobby_invite(data):
    WavedashSDK.join_lobby(data["lobbyId"])

Metadata

Only the host can set metadata. Any member can read it.

WavedashSDK.set_lobby_data(lobby_id, "gameMode", "deathmatch")
var mode = WavedashSDK.get_lobby_data(lobby_id, "gameMode")
WavedashSDK.delete_lobby_data(lobby_id, "gameMode")

Generate a shareable invite link for the current lobby:

const response = await WavedashJS.getLobbyInviteLink(true); // true copies to clipboard
if (response.success) {
  console.log("Invite link:", response.data);
}

Events

EventDescription
LOBBY_JOINEDSuccessfully joined a lobby
LOBBY_USERS_UPDATEDA user joined or left
LOBBY_MESSAGENew message received
LOBBY_DATA_UPDATEDMetadata changed
LOBBY_KICKEDRemoved from lobby
LOBBY_INVITEReceived lobby invitation