Skip to content

Commit

Permalink
Merge pull request #200 from Ughuuu/update-authoritative-client
Browse files Browse the repository at this point in the history
Update authoritative client
  • Loading branch information
Bioblaze authored Dec 16, 2024
2 parents 69577f4 + cac261c commit f42b69e
Show file tree
Hide file tree
Showing 16 changed files with 1,657 additions and 372 deletions.
4 changes: 2 additions & 2 deletions modules/blazium_sdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def get_doc_classes():
"ViewLobbyResponse",
"ViewLobbyResult",
"AuthoritativeClient",
"LobbyCallResponse",
"LobbyCallResult",
"AuthoritativeResponse",
"AuthoritativeResult",
"POGRClient",
"POGRResult",
"POGRResponse",
Expand Down
292 changes: 287 additions & 5 deletions modules/blazium_sdk/doc_classes/AuthoritativeClient.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,306 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AuthoritativeClient" inherits="LobbyClient" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<class name="AuthoritativeClient" inherits="BlaziumClient" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A lobby client that is authoritative.
Node for connecting to the Blazium Lobby service. Offers authoritative lobby making features.
</brief_description>
<description>
A lobby client that is authoritative.
The [AuthoritativeClient] node provides an interface for connecting to the Blazium Authoritative service. There is a free instance hosted on the [url=https://blazium.app]blazium.app[/url] 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 [method 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 [method disconnect_from_lobby] method at the end of the game.
[b]Note:[/b] 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:
- [member peer]: The current peer. Reflects changes to the self peer.
- [member peers]: The lobby peers. Reflects changes to all peers.
- [member lobby]: The lobby. Reflects changes to the lobby.
</description>
<tutorials>
</tutorials>
<methods>
<method name="add_lobby_tags">
<return type="LobbyResponse" />
<param index="0" name="tags" type="Dictionary" />
<description>
Add tags to the lobby. Only works if you are host.
Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
Generates [signal lobby_tagged].
</description>
</method>
<method name="connect_to_lobby">
<return type="bool" />
<description>
Connect to a Blazium Lobby Server using the [member game_id] and [member server_url].
Generates [signal connected_to_lobby] signal if successful.
</description>
</method>
<method name="create_lobby">
<return type="ViewLobbyResponse" />
<param index="0" name="title" type="String" />
<param index="1" name="tags" type="Dictionary" default="{}" />
<param index="2" name="max_players" type="int" default="4" />
<param index="3" name="password" type="String" default="&quot;&quot;" />
<description>
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 [signal ViewLobbyResponse.finished] signal that is emitted when finished.
Generates [signal lobby_created] signal.
</description>
</method>
<method name="del_lobby_tags">
<return type="LobbyResponse" />
<param index="0" name="keys" type="String[]" />
<description>
Delete one or more keys from the lobby tags. Only works if you are host.
Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
Generates [signal lobby_tagged].
</description>
</method>
<method name="disconnect_from_lobby">
<return type="void" />
<description>
Disconnect from the lobby server.
Generates [signal disconnected_from_lobby] signal.
</description>
</method>
<method name="is_host">
<return type="bool" />
<description>
Returns true if you are the host of the current lobby.
</description>
</method>
<method name="join_lobby">
<return type="ViewLobbyResponse" />
<param index="0" name="lobby_id" type="String" />
<param index="1" name="password" type="String" default="&quot;&quot;" />
<description>
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 [signal ViewLobbyResponse.finished] signal that is emitted when finished.
Generates [signal lobby_joined].
</description>
</method>
<method name="kick_peer">
<return type="LobbyResponse" />
<param index="0" name="peer_id" type="String" />
<description>
Kick a peer. You need to be host to do so.
Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
Generates [signal peer_left] signal with kicked set to true.
</description>
</method>
<method name="leave_lobby">
<return type="LobbyResponse" />
<description>
Leave a lobby. You need to be in a lobby to leave one.
Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
Generates [signal lobby_left].
</description>
</method>
<method name="list_lobbies">
<return type="ListLobbyResponse" />
<param index="0" name="tags" type="Dictionary" default="{}" />
<param index="1" name="start" type="int" default="0" />
<param index="2" name="count" type="int" default="10" />
<description>
Lists all lobbies. Lobbies that are sealed won't show in the list, except if you disconnected and trying to reconnect to a lobby.
</description>
</method>
<method name="lobby_call">
<return type="LobbyCallResponse" />
<return type="AuthoritativeResponse" />
<param index="0" name="method" type="String" />
<param index="1" name="args" type="Array" />
<description>
Call a method on the server.
</description>
</method>
<method name="send_chat_message">
<return type="LobbyResponse" />
<param index="0" name="chat_message" type="String" />
<description>
Send a chat message. Only works if you are in a lobby.
Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
Generates [signal peer_messaged].
</description>
</method>
<method name="set_lobby_ready">
<return type="LobbyResponse" />
<param index="0" name="ready" type="bool" />
<description>
Ready up in the lobby. You need to be in a lobby and unready to run this.
Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
Generates [signal peer_ready].
</description>
</method>
<method name="set_lobby_sealed">
<return type="LobbyResponse" />
<param index="0" name="seal" type="bool" />
<description>
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 [signal LobbyResponse.finished] signal that is emitted when finished.
Generates [signal lobby_sealed].
</description>
</method>
<method name="set_peer_name">
<return type="LobbyResponse" />
<param index="0" name="peer_name" type="String" />
<description>
Set your peer name.
Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
Generates [signal peer_named] signal if you are in lobby.
</description>
</method>
<method name="view_lobby">
<return type="ViewLobbyResponse" />
<param index="0" name="lobby_id" type="String" default="&quot;&quot;" />
<param index="1" name="password" type="String" default="&quot;&quot;" />
<description>
View data from a lobby. Returns lobby settings and peers.
Returns a [ViewLobbyResponse] object that has a [signal ViewLobbyResponse.finished] signal that is emitted when finished.
</description>
</method>
</methods>
<members>
<member name="server_url" type="String" setter="set_server_url" getter="get_server_url" overrides="LobbyClient" default="&quot;wss://authlobby.blazium.app/connect&quot;" />
<member name="connected" type="bool" setter="" getter="get_connected" default="false">
True if the client is connected, else false.
</member>
<member name="game_id" type="String" setter="set_game_id" getter="get_game_id" default="&quot;&quot;">
The game id.
</member>
<member name="lobby" type="LobbyInfo" setter="" getter="get_lobby">
The current lobby. Reflects changes to the lobby.
</member>
<member name="peer" type="LobbyPeer" setter="" getter="get_peer">
The current peer. Reflects changes to the self peer.
</member>
<member name="peers" type="LobbyPeer[]" setter="" getter="get_peers" default="[]">
The lobby peers. Reflects changes to all peers.
</member>
<member name="reconnection_token" type="String" setter="set_reconnection_token" getter="get_reconnection_token" default="&quot;&quot;">
Reconnection token.
</member>
<member name="server_url" type="String" setter="set_server_url" getter="get_server_url" default="&quot;wss://authlobby.blazium.app/connect&quot;">
Set to what url this lobby should connect to.
</member>
</members>
<signals>
<signal name="connected_to_lobby">
<param index="0" name="peer" type="LobbyPeer" />
<param index="1" name="reconnection_token" type="String" />
<description>
Signal generated after you connect to the lobby.
</description>
</signal>
<signal name="disconnected_from_lobby">
<param index="0" name="reason" type="String" />
<description>
Signal generated after you disconnect from the lobby.
</description>
</signal>
<signal name="lobby_created">
<param index="0" name="lobby" type="LobbyInfo" />
<param index="1" name="peers" type="LobbyPeer[]" />
<description>
Signal generated after a lobby is created.
</description>
</signal>
<signal name="lobby_joined">
<param index="0" name="lobby" type="LobbyInfo" />
<param index="1" name="peers" type="LobbyPeer[]" />
<description>
Signal generated after you joint a lobby.
</description>
</signal>
<signal name="lobby_left">
<param index="0" name="kicked" type="bool" />
<description>
Signal generated after you leave a lobby.
</description>
</signal>
<signal name="lobby_notified">
<param index="0" name="data" type="Object" />
<param index="1" name="from_peer" type="LobbyPeer" />
<description>
Signal generated after a notification is received.
</description>
</signal>
<signal name="lobby_sealed">
<param index="0" name="sealed" type="bool" />
<description>
Signal generated after the host seals the lobby.
</description>
</signal>
<signal name="lobby_tagged">
<param index="0" name="tags" type="Dictionary" />
<description>
Signal generated after the host updated the tags of the lobby
</description>
</signal>
<signal name="log_updated">
<param index="0" name="command" type="String" />
<param index="1" name="logs" type="String" />
<description>
Signals a log from a command.
</description>
</signal>
<signal name="peer_disconnected">
<param index="0" name="peer" type="LobbyPeer" />
<description>
Signal generated after a peer disconnects. If they don't reconnect they will be removed.
</description>
</signal>
<signal name="peer_joined">
<param index="0" name="peer" type="LobbyPeer" />
<description>
Signal generated after a peer joins the lobby.
</description>
</signal>
<signal name="peer_left">
<param index="0" name="peer" type="LobbyPeer" />
<param index="1" name="kicked" type="bool" />
<description>
Signal generated after a peer leaves the lobby.
</description>
</signal>
<signal name="peer_messaged">
<param index="0" name="peer" type="LobbyPeer" />
<param index="1" name="chat_message" type="String" />
<description>
Signal generated after a peer sends a chat message.
</description>
</signal>
<signal name="peer_named">
<param index="0" name="peer" type="LobbyPeer" />
<description>
Signal generated after a peer names himself.
</description>
</signal>
<signal name="peer_ready">
<param index="0" name="peer" type="LobbyPeer" />
<param index="1" name="is_ready" type="bool" />
<description>
Signal generated after a peer is ready.
</description>
</signal>
<signal name="peer_reconnected">
<param index="0" name="peer" type="LobbyPeer" />
<description>
Signal generated after a peer reconnects.
</description>
</signal>
<signal name="received_lobby_data">
<param index="0" name="data" type="Object" />
<description>
Signal generated after data is sent to the lobby.
</description>
</signal>
<signal name="received_peer_data">
<param index="0" name="data" type="Object" />
<param index="1" name="to_peer" type="LobbyPeer" />
<description>
Signal generated after data is sent to peer.
</description>
</signal>
</signals>
</class>
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="LobbyCallResponse" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<class name="AuthoritativeResponse" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Response from a [method AuthoritativeClient.lobby_call] call.
</brief_description>
<description>
Response from a [method AuthoritativeClient.lobby_call] call. Await on [signal finished] signal to get the [LobbyCallResult].
Response from a [method AuthoritativeClient.lobby_call] call. Await on [signal finished] signal to get the [AuthoritativeResult].
</description>
<tutorials>
</tutorials>
<signals>
<signal name="finished">
<param index="0" name="result" type="LobbyCallResult" />
<param index="0" name="result" type="AuthoritativeResult" />
<description>
Signal emitted when the request is finished.
</description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="LobbyCallResult" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<class name="AuthoritativeResult" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A result from a [LobbyCallResponse].
A result from a [AuthoritativeResponse].
</brief_description>
<description>
A result from a [LobbyCallResponse]. Contains either result or error.
A result from a [AuthoritativeResponse]. Contains either result or error.
</description>
<tutorials>
</tutorials>
Expand Down
2 changes: 1 addition & 1 deletion modules/blazium_sdk/icons/AuthoritativeClient.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f42b69e

Please sign in to comment.