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:
Listen to all the signals you are interested in.
Connect to the server using connect_to_server method.
Call any other methods to create, view or join lobbies, as well as add data to them.
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.
host_data: The current lobby private data. Only works if you are host.
peer_data: The current peer private data.
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ΒΆ
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
MethodsΒΆ
add_lobby_data(data: Dictionary, is_private: bool = false) |
|
add_lobby_tags(tags: Dictionary) |
|
add_peer_data(data: Dictionary, target_peer: String, is_private: bool = false) |
|
add_peer_user_data(data: Dictionary) |
|
add_peers_data(data: Dictionary, is_private: bool = false) |
|
create_lobby(title: String, sealed: bool, tags: Dictionary = {}, max_players: int = 4, password: String = "") |
|
del_lobby_data(keys: Array[String], is_private: bool = false) |
|
del_lobby_tags(keys: Array[String]) |
|
del_peer_data(keys: Array[String], target_peer: String, is_private: bool = false) |
|
del_peer_user_data(keys: Array[String]) |
|
del_peers_data(keys: Array[String], is_private: bool = false) |
|
is_host() |
|
join_lobby(lobby_id: String, password: String = "") |
|
notify_lobby(data: Variant) |
|
notify_peer(data: Variant, target_peer: String) |
|
quick_join(title: String, tags: Dictionary = {}, max_players: int = 4) |
|
send_chat_message(chat_message: String) |
|
set_lobby_ready(ready: bool) |
|
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.
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_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.
received_peer_user_data(peer: LobbyPeer, data: Object) π
Signal generated after user data is sent to peer.
Property DescriptionsΒΆ
bool get_connected()
True if the client is connected, else false.
String discord_embedded_app/path = "blazium/lobby/connect"
π
Set to what path this client should use when connecting to the discord embedded app.
The game id.
Dictionary host_data = {}
π
Dictionary get_host_data()
The current lobby private data. Only works if you are host.
LobbyInfo get_lobby()
The current lobby. Reflects changes to the lobby.
LobbyPeer get_peer()
The current peer. Reflects changes to the self peer.
Dictionary peer_data = {}
π
Dictionary get_peer_data()
The current peer private data.
Array[LobbyPeer] peers = []
π
The lobby peers. Reflects changes to all peers.
String reconnection_token = ""
π
Reconnection token.
String server_url = "wss://lobby.blazium.app/connect"
π
Set to what url this lobby should connect to.
For discord embedded app environment, replaces the url with client_id.discordsays.com/.proxy/blazium/lobby/connect if left default, where client_id is the client id from the discord embedded app url (automatically detected).
Method DescriptionsΒΆ
LobbyResponse add_lobby_data(data: Dictionary, is_private: bool = false) π
Add data 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 received_lobby_data.
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_data(data: Dictionary, target_peer: String, is_private: bool = false) π
Add data to a peer. 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 received_peer_data.
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 add_peers_data(data: Dictionary, is_private: bool = false) π
Add data to all peers. 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 received_peer_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_data(keys: Array[String], is_private: bool = false) π
Delete one or more keys from the lobby data. 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 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.
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_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.
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_data.
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 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.
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_data.
LobbyResponse disconnect_from_server() π
Disconnect from the lobby server.
Needs connect_to_server to be called first.
Generates disconnected_from_server signal.
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.
LobbyResponse notify_lobby(data: Variant) π
Send a notification either to the host, or if you are host send data to all peers.
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_notified signal.
LobbyResponse notify_peer(data: Variant, target_peer: String) π
Send a notification to a peer, works only 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_notified signal.
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.