Skip to content

Commit

Permalink
add master server node
Browse files Browse the repository at this point in the history
add master server node

fix default values

fix some defaults
  • Loading branch information
Ughuuu committed Dec 14, 2024
1 parent 86a7277 commit 936fd7d
Show file tree
Hide file tree
Showing 13 changed files with 538 additions and 25 deletions.
6 changes: 6 additions & 0 deletions modules/blazium_sdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def get_doc_classes():
"POGRClient",
"POGRResult",
"POGRResponse",
"MasterServerClient",
"MasterServerResult",
"MasterServerResponse",
"MasterServerListResult",
"MasterServerListResponse",
"GameServerInfo",
]


Expand Down
37 changes: 37 additions & 0 deletions modules/blazium_sdk/doc_classes/GameServerInfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GameServerInfo" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Game server info used by the [MasterServerClient].
</brief_description>
<description>
Game server info used by the [MasterServerClient]. Used to create or update a game server.
</description>
<tutorials>
</tutorials>
<members>
<member name="description" type="String" setter="set_description" getter="get_description" default="&quot;&quot;">
Description of the game server.
</member>
<member name="game_name" type="String" setter="set_game_name" getter="get_game_name" default="&quot;&quot;">
Name of the game server.
</member>
<member name="id" type="String" setter="set_id" getter="get_id" default="&quot;&quot;">
Id of the game server. Generated after call to create game server.
</member>
<member name="ip_address" type="String" setter="set_ip_address" getter="get_ip_address" default="&quot;&quot;">
Ip address of the game server.
</member>
<member name="max_players" type="int" setter="set_max_players" getter="get_max_players" default="0">
Max players of the game server.
</member>
<member name="players" type="int" setter="set_players" getter="get_players" default="0">
Players of the game server.
</member>
<member name="port" type="int" setter="set_port" getter="get_port" default="0">
Port of the game server.
</member>
<member name="version" type="String" setter="set_version" getter="get_version" default="&quot;&quot;">
Version of the game server.
</member>
</members>
</class>
41 changes: 41 additions & 0 deletions modules/blazium_sdk/doc_classes/MasterServerClient.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="MasterServerClient" inherits="BlaziumClient" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A node used to connect to a master server.
</brief_description>
<description>
A node used to connect to a master server.
</description>
<tutorials>
</tutorials>
<methods>
<method name="create_game">
<return type="MasterServerResponse" />
<param index="0" name="game_server_info" type="GameServerInfo" />
<description>
Create a game server.
</description>
</method>
<method name="recent_games">
<return type="MasterServerListResponse" />
<description>
Get a list of recent games.
</description>
</method>
<method name="update_game">
<return type="MasterServerResponse" />
<param index="0" name="game_server_info" type="GameServerInfo" />
<description>
Update a game server.
</description>
</method>
</methods>
<members>
<member name="game_id" type="String" setter="set_game_id" getter="get_game_id" default="&quot;&quot;">
Game id of the game server.
</member>
<member name="server_url" type="String" setter="set_server_url" getter="get_server_url" default="&quot;https://masterserver.blazium.app/api/v1&quot;">
Set to what url this master server should connect to.
</member>
</members>
</class>
19 changes: 19 additions & 0 deletions modules/blazium_sdk/doc_classes/MasterServerListResponse.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="MasterServerListResponse" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Response from a list games request.
</brief_description>
<description>
Response from a list games request.
</description>
<tutorials>
</tutorials>
<signals>
<signal name="finished">
<param index="0" name="result" type="MasterServerResult" />
<description>
Signal emitted when the request is finished.
</description>
</signal>
</signals>
</class>
27 changes: 27 additions & 0 deletions modules/blazium_sdk/doc_classes/MasterServerListResult.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="MasterServerListResult" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A result from a [MasterServerListResponse].
</brief_description>
<description>
A result from a [MasterServerListResponse]. Contains either result or error.
</description>
<tutorials>
</tutorials>
<methods>
<method name="has_error" qualifiers="const">
<return type="bool" />
<description>
Returns true if there is an error.
</description>
</method>
</methods>
<members>
<member name="error" type="String" setter="" getter="get_error" default="&quot;&quot;">
The error message.
</member>
<member name="results" type="GameServerInfo[]" setter="" getter="get_results" default="[]">
The results.
</member>
</members>
</class>
19 changes: 19 additions & 0 deletions modules/blazium_sdk/doc_classes/MasterServerResponse.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="MasterServerResponse" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Response from a create or update game request.
</brief_description>
<description>
Response from a create or update game request.
</description>
<tutorials>
</tutorials>
<signals>
<signal name="finished">
<param index="0" name="result" type="MasterServerResult" />
<description>
Signal emitted when the request is finished.
</description>
</signal>
</signals>
</class>
27 changes: 27 additions & 0 deletions modules/blazium_sdk/doc_classes/MasterServerResult.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="MasterServerResult" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A result from a [MasterServerResponse].
</brief_description>
<description>
A result from a [MasterServerResponse]. Contains either result or error.
</description>
<tutorials>
</tutorials>
<methods>
<method name="has_error" qualifiers="const">
<return type="bool" />
<description>
Returns true if there is an error.
</description>
</method>
</methods>
<members>
<member name="error" type="String" setter="" getter="get_error" default="&quot;&quot;">
Gets the error message.
</member>
<member name="result" type="GameServerInfo" setter="" getter="get_result">
Gets the result.
</member>
</members>
</class>
1 change: 1 addition & 0 deletions modules/blazium_sdk/icons/MasterServerClient.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion modules/blazium_sdk/lobby/lobby_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "./authoritative_client.h"
#include "scene/main/node.h"
LobbyClient::LobbyClient() {
server_url = "wss://lobby.blazium.app/connect";
lobby.instantiate();
peer.instantiate();
_socket = Ref<WebSocketPeer>(WebSocketPeer::create());
Expand Down
41 changes: 19 additions & 22 deletions modules/blazium_sdk/lobby/lobby_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@

class LobbyInfo : public Resource {
GDCLASS(LobbyInfo, Resource);
String id;
String lobby_name;
String host;
String host_name;
Dictionary tags;
Dictionary data;
String id = "";
String lobby_name = "";
String host = "";
String host_name = "";
Dictionary tags = Dictionary();
Dictionary data = Dictionary();
int max_players = 0;
int players = 0;
bool sealed = false;
Expand Down Expand Up @@ -127,10 +127,10 @@ class LobbyInfo : public Resource {

class LobbyPeer : public Resource {
GDCLASS(LobbyPeer, Resource);
String id;
String peer_name;
String id = "";
String peer_name = "";
bool ready = false;
Dictionary data;
Dictionary data = Dictionary();

protected:
static void _bind_methods() {
Expand Down Expand Up @@ -175,14 +175,14 @@ class LobbyClient : public BlaziumClient {
GDCLASS(LobbyClient, BlaziumClient);

protected:
String server_url;
String reconnection_token;
String server_url = "wss://lobby.blazium.app/connect";
String reconnection_token = "";
String game_id = "";
Dictionary host_data;
Dictionary peer_data;
Dictionary host_data = Dictionary();
Dictionary peer_data = Dictionary();
Ref<LobbyInfo> lobby;
Ref<LobbyPeer> peer;
TypedArray<LobbyPeer> peers;
TypedArray<LobbyPeer> peers = TypedArray<LobbyPeer>();

public:
class LobbyResponse : public RefCounted {
Expand All @@ -197,7 +197,7 @@ class LobbyClient : public BlaziumClient {
class LobbyResult : public RefCounted {
GDCLASS(LobbyResult, RefCounted);

String error;
String error = "";

protected:
static void _bind_methods() {
Expand Down Expand Up @@ -226,8 +226,8 @@ class LobbyClient : public BlaziumClient {
class ListLobbyResult : public RefCounted {
GDCLASS(ListLobbyResult, RefCounted);

String error;
TypedArray<LobbyInfo> lobbies;
String error = "";
TypedArray<LobbyInfo> lobbies = TypedArray<LobbyInfo>();

protected:
static void _bind_methods() {
Expand All @@ -236,7 +236,6 @@ class LobbyClient : public BlaziumClient {
ClassDB::bind_method(D_METHOD("get_lobbies"), &ListLobbyResult::get_lobbies);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "error"), "", "get_error");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "lobbies", PROPERTY_HINT_ARRAY_TYPE, "LobbyInfo"), "", "get_lobbies");
ADD_PROPERTY_DEFAULT("lobbies", TypedArray<LobbyInfo>());
}

public:
Expand All @@ -260,8 +259,8 @@ class LobbyClient : public BlaziumClient {
public:
class ViewLobbyResult : public RefCounted {
GDCLASS(ViewLobbyResult, RefCounted);
String error;
TypedArray<LobbyPeer> peers_info;
String error = "";
TypedArray<LobbyPeer> peers_info = TypedArray<LobbyPeer>();
Ref<LobbyInfo> lobby_info;

protected:
Expand All @@ -272,8 +271,6 @@ class LobbyClient : public BlaziumClient {
ClassDB::bind_method(D_METHOD("get_lobby"), &ViewLobbyResult::get_lobby);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "peers", PROPERTY_HINT_ARRAY_TYPE, "LobbyPeer"), "", "get_peers");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "lobby", PROPERTY_HINT_RESOURCE_TYPE, "LobbyInfo"), "", "get_lobby");
ADD_PROPERTY_DEFAULT("lobby", Ref<LobbyInfo>());
ADD_PROPERTY_DEFAULT("peers", TypedArray<LobbyPeer>());
ADD_PROPERTY(PropertyInfo(Variant::STRING, "error"), "", "get_error");
}

Expand Down
Loading

0 comments on commit 936fd7d

Please sign in to comment.