Up to date

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

ScriptedLobbyClient

Inherits: BlaziumClient < Node < Object

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

Description

The ScriptedLobbyClient node provides an interface for connecting to the Blazium Authoritative 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_server 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_server 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.

  • peer_data: The current peer private data.

Note: The main difference between this service and the non authoritative LobbyClient are:

  • The host cannot set any data or notify peer_disconnected.

  • The received_lobby_data signal doesn't have the is_private parameter.

func _ready():
    disconnected_from_server.connect(_disconnected_from_server)
    var res : LobbyResult = await connect_to_server().finished
    if res.has_error():
        print(res.error)
    var res_view: ViewLobbyResult =await create_lobby("Test lobby", false).finished
    if res_view.has_error():
        print(res_view.error)
    else:
        print(res_view.lobby.lobby_name)
func _disconnected_from_server(reason: String):
    print("Disconnected from server: " + reason)

Tutorials

Properties

bool

connected

false

String

discord_embedded_app/path

"blazium/scriptedlobby/connect"

String

game_id

""

LobbyInfo

lobby

LobbyPeer

peer

Dictionary

peer_data

{}

Array[LobbyPeer]

peers

[]

String

reconnection_token

""

String

server_url

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

Methods

LobbyResponse

add_lobby_tags(tags: Dictionary)

LobbyResponse

add_peer_user_data(data: Dictionary)

LobbyResponse

connect_to_server()

ViewLobbyResponse

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

LobbyResponse

del_lobby_tags(keys: Array[String])

LobbyResponse

del_peer_user_data(keys: Array[String])

LobbyResponse

disconnect_from_server()

bool

is_host()

ViewLobbyResponse

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

LobbyResponse

kick_peer(peer_id: String)

LobbyResponse

leave_lobby()

LobbyResponse

list_lobbies()

ScriptedLobbyResponse

lobby_call(method: String, args: Array = [])

ViewLobbyResponse

quick_join(title: String, tags: Dictionary = {}, max_players: int = 4)

LobbyResponse

send_chat_message(chat_message: String)

LobbyResponse

set_lobby_ready(ready: bool)

LobbyResponse

set_lobby_sealed(seal: bool)


Signals

connected_to_server(peer: LobbyPeer, reconnection_token: String) 🔗

Signal generated after you connect to the lobby.


disconnected_from_server(reason: String) 🔗

Signal generated after you disconnect from the lobby.


lobbies_listed(lobbies: Array[LobbyInfo]) 🔗

Signal generated after the lobbies are listed, or when a new lobby is created or removed.


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) 🔗

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_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) 🔗

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.


received_peer_user_data(peer: LobbyPeer, data: Object) 🔗

Signal generated after user data is sent to peer.


Property Descriptions

bool connected = false 🔗

  • bool get_connected()

True if the client is connected, else false.


String discord_embedded_app/path = "blazium/scriptedlobby/connect" 🔗

  • void set_override_discord_path(value: String)

  • String get_override_discord_path()

Set to what path this client should use when connecting to the discord embedded app.


String game_id = "" 🔗

The game id.


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://scriptedlobby.blazium.app/connect" 🔗

  • void set_server_url(value: String)

  • String get_server_url()

Set to what url this lobby should connect to.

For discord embedded app environment, replaces the url with client_id.discordsays.com/.proxy/blazium/scriptedlobby/connect if left default, where client_id is the client id from the discord embedded app url (automatically detected).


Method Descriptions

LobbyResponse add_lobby_tags(tags: Dictionary) 🔗

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

Needs connect_to_server to be called first.

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

Generates lobby_tagged.


LobbyResponse add_peer_user_data(data: Dictionary) 🔗

Add user data to your own peer.

Needs connect_to_server to be called first.

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

Generates received_peer_user_data.


LobbyResponse connect_to_server() 🔗

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

Generates connected_to_server signal if successful.


ViewLobbyResponse create_lobby(title: String, sealed: bool, 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.

Needs connect_to_server to be called first.

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

Generates lobby_created signal.


LobbyResponse del_lobby_tags(keys: Array[String]) 🔗

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

Needs connect_to_server to be called first.

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

Generates lobby_tagged.


LobbyResponse del_peer_user_data(keys: Array[String]) 🔗

Delete one or more keys from the peers user data.

Needs connect_to_server to be called first.

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

Generates received_peer_user_data.


LobbyResponse disconnect_from_server() 🔗

Disconnect from the lobby server.

Needs connect_to_server to be called first.

Generates disconnected_from_server 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.

Needs connect_to_server to be called first.

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.

Needs connect_to_server to be called first.

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.

Needs connect_to_server to be called first.

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

Generates lobby_left.


LobbyResponse list_lobbies() 🔗

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

Needs connect_to_server to be called first.

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

Generates lobbies_listed.


ScriptedLobbyResponse lobby_call(method: String, args: Array = []) 🔗

Call a method on the server.

Needs connect_to_server to be called first.

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


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

Quick join a lobby or create one if none exist. If you are already in a lobby, you cannot join another one. You need to leave first.

Needs connect_to_server to be called first.

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

Generates either lobby_joined or lobby_created.


LobbyResponse send_chat_message(chat_message: String) 🔗

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

Needs connect_to_server to be called first.

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.

Needs connect_to_server to be called first.

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.

Needs connect_to_server to be called first.

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

Generates lobby_sealed.