Up to date

This page is up to date for Godot 4.3. If you still find outdated information, please open an issue.

LobbyClient

Inherits: BlaziumClient < Node < Object

Node for connecting to the Blazium Lobby service. Offers non-authoritative lobby making features.

Description

The LobbyClient node provides an interface for connecting to the Blazium Lobby service. There is a free instance hosted on the blazium.app domain that is used by default.

The normal flow is as follows:

  1. Listen to all the signals you are interested in.

  2. Connect to the server using connect_to_lobby method.

  3. Call any other methods to create, view or join lobbies, as well as add data to them.

  4. Close the session using disconnect_from_lobby method at the end of the game.

Note: Some methods are non blocking and can be awaited in order to get the result.

There are also members on this class that are automatically updated as the lobby gets updated, such as:

  • peer: The current peer. Reflects changes to the self peer.

  • peers: The lobby peers. Reflects changes to all peers.

  • lobby: The lobby. Reflects changes to the lobby.

  • host_data: The current lobby private data. Only works if you are host.

  • peer_data: The current peer private data.

Tutorials

Properties

bool

connected

false

String

game_id

""

Dictionary

host_data

{}

LobbyInfo

lobby

LobbyPeer

peer

Dictionary

peer_data

{}

Array[LobbyPeer]

peers

[]

String

reconnection_token

""

String

server_url

"wss://lobby.blazium.app/connect"

Methods

LobbyResponse

add_lobby_data(data: Dictionary, is_private: bool = false)

LobbyResponse

add_lobby_tags(tags: Dictionary)

LobbyResponse

add_peer_data(data: Dictionary, target_peer: String, is_private: bool = false)

LobbyResponse

add_peers_data(data: Dictionary, is_private: bool = false)

bool

connect_to_lobby()

ViewLobbyResponse

create_lobby(title: String, tags: Dictionary = {}, max_players: int = 4, password: String = "")

LobbyResponse

del_lobby_data(keys: Array[String], is_private: bool = false)

LobbyResponse

del_lobby_tags(keys: Array[String])

LobbyResponse

del_peer_data(keys: Array[String], target_peer: String, is_private: bool = false)

LobbyResponse

del_peers_data(keys: Array[String], is_private: bool = false)

void

disconnect_from_lobby()

bool

is_host()

ViewLobbyResponse

join_lobby(lobby_id: String, password: String = "")

LobbyResponse

kick_peer(peer_id: String)

LobbyResponse

leave_lobby()

ListLobbyResponse

list_lobbies(tags: Dictionary = {}, start: int = 0, count: int = 10)

LobbyResponse

notify_lobby(data: Variant)

LobbyResponse

notify_peer(data: Variant, target_peer: String)

LobbyResponse

send_chat_message(chat_message: String)

LobbyResponse

set_lobby_ready(ready: bool)

LobbyResponse

set_lobby_sealed(seal: bool)

LobbyResponse

set_peer_name(peer_name: String)


Signals

connected_to_lobby(peer: LobbyPeer, reconnection_token: String) 🔗

Signal generated after you connect to the lobby.


disconnected_from_lobby(reason: String) 🔗

Signal generated after you disconnect from the lobby.


lobby_created(lobby: LobbyInfo, peers: Array[LobbyPeer]) 🔗

Signal generated after a lobby is created.


lobby_joined(lobby: LobbyInfo, peers: Array[LobbyPeer]) 🔗

Signal generated after you joint a lobby.


lobby_left(kicked: bool) 🔗

Signal generated after you leave a lobby.


lobby_notified(data: Object, from_peer: LobbyPeer) 🔗

Signal generated after a notification is received.


lobby_sealed(sealed: bool) 🔗

Signal generated after the host seals the lobby.


lobby_tagged(tags: Dictionary) 🔗

Signal generated after the host updated the tags of the lobby


log_updated(command: String, logs: String) 🔗

Signals a log from a command.


peer_disconnected(peer: LobbyPeer) 🔗

Signal generated after a peer disconnects. If they don't reconnect they will be removed.


peer_joined(peer: LobbyPeer) 🔗

Signal generated after a peer joins the lobby.


peer_left(peer: LobbyPeer, kicked: bool) 🔗

Signal generated after a peer leaves the lobby.


peer_messaged(peer: LobbyPeer, chat_message: String) 🔗

Signal generated after a peer sends a chat message.


peer_named(peer: LobbyPeer) 🔗

Signal generated after a peer names himself.


peer_ready(peer: LobbyPeer, is_ready: bool) 🔗

Signal generated after a peer is ready.


peer_reconnected(peer: LobbyPeer) 🔗

Signal generated after a peer reconnects.


received_lobby_data(data: Object, is_private: bool) 🔗

Signal generated after data is sent to the lobby.


received_peer_data(data: Object, to_peer: LobbyPeer, is_private: bool) 🔗

Signal generated after data is sent to peer.


Property Descriptions

bool connected = false 🔗

  • bool get_connected()

True if the client is connected, else false.


String game_id = "" 🔗

The game id.


Dictionary host_data = {} 🔗

The current lobby private data. Only works if you are host.


LobbyInfo lobby 🔗

The current lobby. Reflects changes to the lobby.


LobbyPeer peer 🔗

The current peer. Reflects changes to the self peer.


Dictionary peer_data = {} 🔗

The current peer private data.


Array[LobbyPeer] peers = [] 🔗

The lobby peers. Reflects changes to all peers.


String reconnection_token = "" 🔗

  • void set_reconnection_token(value: String)

  • String get_reconnection_token()

Reconnection token.


String server_url = "wss://lobby.blazium.app/connect" 🔗

  • void set_server_url(value: String)

  • String get_server_url()

Set to what url this lobby should connect to.


Method Descriptions

LobbyResponse add_lobby_data(data: Dictionary, is_private: bool = false) 🔗

Add data to the lobby. Only works if you are host.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates received_lobby_data.


LobbyResponse add_lobby_tags(tags: Dictionary) 🔗

Add tags to the lobby. Only works if you are host.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates lobby_tagged.


LobbyResponse add_peer_data(data: Dictionary, target_peer: String, is_private: bool = false) 🔗

Add data to a peer. Only works if you are host.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates received_peer_data.


LobbyResponse add_peers_data(data: Dictionary, is_private: bool = false) 🔗

Add data to all peers. Only works if you are host.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates received_peer_data.


bool connect_to_lobby() 🔗

Connect to a Blazium Lobby Server using the game_id and server_url.

Generates connected_to_lobby signal if successful.


ViewLobbyResponse create_lobby(title: String, tags: Dictionary = {}, max_players: int = 4, password: String = "") 🔗

Create a lobby and become host. If you are already in a lobby, you cannot create one. You need to leave first.

The new lobby can have a title, tags, max players and password. 0 max players means unlimited.

Returns a ViewLobbyResponse object that has a ViewLobbyResponse.finished signal that is emitted when finished.

Generates lobby_created signal.


LobbyResponse del_lobby_data(keys: Array[String], is_private: bool = false) 🔗

Delete one or more keys from the lobby data. Only works if you are host.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates received_lobby_data.


LobbyResponse del_lobby_tags(keys: Array[String]) 🔗

Delete one or more keys from the lobby tags. Only works if you are host.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates lobby_tagged.


LobbyResponse del_peer_data(keys: Array[String], target_peer: String, is_private: bool = false) 🔗

Delete one or more keys from the peer data. Only works if you are host.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates received_peer_data.


LobbyResponse del_peers_data(keys: Array[String], is_private: bool = false) 🔗

Delete one or more keys from the peers data. Only works if you are host.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates received_peer_data.


void disconnect_from_lobby() 🔗

Disconnect from the lobby server.

Generates disconnected_from_lobby signal.


bool is_host() 🔗

Returns true if you are the host of the current lobby.


ViewLobbyResponse join_lobby(lobby_id: String, password: String = "") 🔗

Join a lobby. If you are already in a lobby, you cannot join another one. You need to leave first.

If the lobby you want to join is password protected, you need to provide the password.

Returns a ViewLobbyResponse object that has a ViewLobbyResponse.finished signal that is emitted when finished.

Generates lobby_joined.


LobbyResponse kick_peer(peer_id: String) 🔗

Kick a peer. You need to be host to do so.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates peer_left signal with kicked set to true.


LobbyResponse leave_lobby() 🔗

Leave a lobby. You need to be in a lobby to leave one.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates lobby_left.


ListLobbyResponse list_lobbies(tags: Dictionary = {}, start: int = 0, count: int = 10) 🔗

Lists all lobbies. Lobbies that are sealed won't show in the list, except if you disconnected and trying to reconnect to a lobby.


LobbyResponse notify_lobby(data: Variant) 🔗

Send a notification either to the host, or if you are host send data to all peers.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates lobby_notified signal.


LobbyResponse notify_peer(data: Variant, target_peer: String) 🔗

Send a notification to a peer, works only if you are host.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates lobby_notified signal.


LobbyResponse send_chat_message(chat_message: String) 🔗

Send a chat message. Only works if you are in a lobby.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates peer_messaged.


LobbyResponse set_lobby_ready(ready: bool) 🔗

Ready up in the lobby. You need to be in a lobby and unready to run this.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates peer_ready.


LobbyResponse set_lobby_sealed(seal: bool) 🔗

Seals the lobby. You need to be the host to do this and the lobby needs to be unsealed.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates lobby_sealed.


LobbyResponse set_peer_name(peer_name: String) 🔗

Set your peer name.

Returns a LobbyResponse object that has a LobbyResponse.finished signal that is emitted when finished.

Generates peer_named signal if you are in lobby.