Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Master Server node and Login node #193

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/blazium_sdk/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ Import("env_modules")

env_blazium_sdk = env_modules.Clone()
env_blazium_sdk.add_source_files(env.modules_sources, "lobby/*.cpp")
env_blazium_sdk.add_source_files(env.modules_sources, "login/*.cpp")
env_blazium_sdk.add_source_files(env.modules_sources, "master_server/*.cpp")
env_blazium_sdk.add_source_files(env.modules_sources, "pogr/*.cpp")
env_blazium_sdk.add_source_files(env.modules_sources, "*.cpp")
9 changes: 9 additions & 0 deletions modules/blazium_sdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ def get_doc_classes():
"POGRClient",
"POGRResult",
"POGRResponse",
"MasterServerClient",
"MasterServerResult",
"MasterServerResponse",
"MasterServerListResult",
"MasterServerListResponse",
"GameServerInfo",
"LoginClient",
"LoginResponse",
"LoginResult",
]


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>
71 changes: 71 additions & 0 deletions modules/blazium_sdk/doc_classes/LoginClient.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="LoginClient" 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 login server.
</brief_description>
<description>
A node used to connect to a login server.
</description>
<tutorials>
</tutorials>
<methods>
<method name="connect_to_server">
<return type="bool" />
<description>
Connect to the server.
</description>
</method>
<method name="disconnect_from_server">
<return type="void" />
<description>
Disconnect from the server.
Generates [signal disconnected_from_server] when disconnected.
</description>
</method>
<method name="request_login_info">
<return type="LoginResponse" />
<param index="0" name="login_type" type="String" />
<description>
Request login info.
</description>
</method>
</methods>
<members>
<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="server_url" type="String" setter="set_server_url" getter="get_server_url" default="&quot;wss://login.blazium.app/connect&quot;">
Set to what url this login should connect to.
</member>
</members>
<signals>
<signal name="connected_to_server">
<description>
Signal emitted when the client connects to the server.
</description>
</signal>
<signal name="disconnected_from_server">
<param index="0" name="reason" type="String" />
<description>
Signal emitted when the client disconnects from the server.
</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="received_jwt">
<param index="0" name="jwt" type="String" />
<param index="1" name="type" type="String" />
<description>
Signal emitted when a JWT is received.
</description>
</signal>
</signals>
</class>
19 changes: 19 additions & 0 deletions modules/blazium_sdk/doc_classes/LoginResponse.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="LoginResponse" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Response from a connect request.
</brief_description>
<description>
Response from a connect request.
</description>
<tutorials>
</tutorials>
<signals>
<signal name="finished">
<param index="0" name="result" type="LobbyResult" />
<description>
Signal emitted when the request is finished.
</description>
</signal>
</signals>
</class>
30 changes: 30 additions & 0 deletions modules/blazium_sdk/doc_classes/LoginResult.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="LoginResult" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A result from a [LoginResponse].
</brief_description>
<description>
A result from a [LoginResponse].
</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="login_type" type="String" setter="" getter="get_login_type" default="&quot;&quot;">
The login type.
</member>
<member name="login_url" type="String" setter="" getter="get_login_url" default="&quot;&quot;">
The login url.
</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/LoginClient.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: 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.
3 changes: 1 addition & 2 deletions 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 Expand Up @@ -140,7 +139,6 @@ bool LobbyClient::connect_to_lobby() {
connected = false;
return false;
}
connected = true;
set_process_internal(true);
emit_signal("log_updated", "connect_to_lobby", "Connected to: " + url);
return true;
Expand Down Expand Up @@ -581,6 +579,7 @@ void LobbyClient::_notification(int p_what) {

WebSocketPeer::State state = _socket->get_ready_state();
if (state == WebSocketPeer::STATE_OPEN) {
connected = true;
while (_socket->get_available_packet_count() > 0) {
Vector<uint8_t> packet_buffer;
Error err = _socket->get_packet_buffer(packet_buffer);
Expand Down
Loading
Loading