diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml
index 9a8a4a8f1912..31903ca4ff23 100644
--- a/.github/workflows/static_checks.yml
+++ b/.github/workflows/static_checks.yml
@@ -15,6 +15,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 2
+ submodules: recursive
- name: Install APT dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 000000000000..0f630a3527f3
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,4 @@
+[submodule "modules/blazium_sdk"]
+ path = modules/blazium_sdk
+ url = https://github.com/blazium-engine/blazium-sdk-module
+ branch = 4.3
diff --git a/modules/blazium_sdk b/modules/blazium_sdk
new file mode 160000
index 000000000000..d6a2a519bf3b
--- /dev/null
+++ b/modules/blazium_sdk
@@ -0,0 +1 @@
+Subproject commit d6a2a519bf3bed0983ec14bfc28a7af97a869f35
diff --git a/modules/blazium_sdk/SCsub b/modules/blazium_sdk/SCsub
deleted file mode 100644
index 2feda23b8a92..000000000000
--- a/modules/blazium_sdk/SCsub
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env python
-
-Import("env")
-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")
diff --git a/modules/blazium_sdk/blazium_client.h b/modules/blazium_sdk/blazium_client.h
deleted file mode 100644
index 878a59a51228..000000000000
--- a/modules/blazium_sdk/blazium_client.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**************************************************************************/
-/* blazium_client.h */
-/**************************************************************************/
-/* This file is part of: */
-/* BLAZIUM ENGINE */
-/* https://blazium.app */
-/**************************************************************************/
-/* Copyright (c) 2024-present Blazium Engine contributors. */
-/* Copyright (c) 2024 Dragos Daian, Randolph William Aarseth II. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef BLAZIUM_CLIENT_H
-#define BLAZIUM_CLIENT_H
-
-#include "scene/main/node.h"
-
-class BlaziumClient : public Node {
- GDCLASS(BlaziumClient, Node);
-
-protected:
- static void _bind_methods() {}
-};
-
-#endif // BLAZIUM_CLIENT_H
diff --git a/modules/blazium_sdk/config.py b/modules/blazium_sdk/config.py
deleted file mode 100644
index 7cbca68fc420..000000000000
--- a/modules/blazium_sdk/config.py
+++ /dev/null
@@ -1,40 +0,0 @@
-def can_build(env, platform):
- return True
-
-
-def configure(env):
- pass
-
-
-def get_doc_classes():
- return [
- "LobbyClient",
- "BlaziumClient",
- "LobbyInfo",
- "LobbyPeer",
- "LobbyResponse",
- "LobbyResult",
- "ListLobbyResponse",
- "ListLobbyResult",
- "ViewLobbyResponse",
- "ViewLobbyResult",
- "AuthoritativeLobbyClient",
- "AuthoritativeLobbyResponse",
- "AuthoritativeLobbyResult",
- "POGRClient",
- "POGRResult",
- "POGRResponse",
- "MasterServerClient",
- "MasterServerResult",
- "MasterServerResponse",
- "MasterServerListResult",
- "MasterServerListResponse",
- "GameServerInfo",
- "LoginClient",
- "LoginResponse",
- "LoginResult",
- ]
-
-
-def get_doc_path():
- return "doc_classes"
diff --git a/modules/blazium_sdk/doc_classes/AuthoritativeLobbyClient.xml b/modules/blazium_sdk/doc_classes/AuthoritativeLobbyClient.xml
deleted file mode 100644
index cd08b6301f00..000000000000
--- a/modules/blazium_sdk/doc_classes/AuthoritativeLobbyClient.xml
+++ /dev/null
@@ -1,316 +0,0 @@
-
-
-
- Node for connecting to the Blazium Lobby service. Offers authoritative lobby making features.
-
-
- The [AuthoritativeLobbyClient] 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.
- - [member peer_data]: The current peer private data.
-
- [b]Note:[/b] The main difference between this service and the non authoritative [LobbyClient] are:
- - The host cannot set any data or notify peer_disconnected.
- - The [signal received_lobby_data] signal doesn't have the [code]is_private[/code] parameter.
-
-
- https://github.com/blazium-engine/blazium-lobby-sdk
-
-
-
-
-
-
- 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].
-
-
-
-
-
-
- Add user data to your own peer.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal received_peer_user_data].
-
-
-
-
-
- Connect to a Blazium Lobby Server using the [member game_id] and [member server_url].
- Generates [signal connected_to_lobby] signal if successful.
-
-
-
-
-
-
-
-
-
- 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.
-
-
-
-
-
-
- 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].
-
-
-
-
-
-
- Delete one or more keys from the peers user data.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal received_peer_user_data].
-
-
-
-
-
- Disconnect from the lobby server.
- Generates [signal disconnected_from_lobby] signal.
-
-
-
-
-
- Returns true if you are the host of the current lobby.
-
-
-
-
-
-
-
- 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].
-
-
-
-
-
-
- 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.
-
-
-
-
-
- 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].
-
-
-
-
-
-
-
-
- Lists all lobbies. Lobbies that are sealed won't show in the list, except if you disconnected and trying to reconnect to a lobby.
-
-
-
-
-
-
-
- Call a method on the server.
-
-
-
-
-
-
- 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].
-
-
-
-
-
-
- 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].
-
-
-
-
-
-
- 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].
-
-
-
-
-
- True if the client is connected, else false.
-
-
- The game id.
-
-
- The current lobby. Reflects changes to the lobby.
-
-
- The current peer. Reflects changes to the self peer.
-
-
- The current peer private data.
-
-
- The lobby peers. Reflects changes to all peers.
-
-
- Reconnection token.
-
-
- Set to what url this lobby should connect to.
-
-
-
-
-
-
-
- Signal generated after you connect to the lobby.
-
-
-
-
-
- Signal generated after you disconnect from the lobby.
-
-
-
-
-
-
- Signal generated after a lobby is created.
-
-
-
-
-
-
- Signal generated after you joint a lobby.
-
-
-
-
-
- Signal generated after you leave a lobby.
-
-
-
-
-
- Signal generated after a notification is received.
-
-
-
-
-
- Signal generated after the host seals the lobby.
-
-
-
-
-
- Signal generated after the host updated the tags of the lobby
-
-
-
-
-
-
- Signals a log from a command.
-
-
-
-
-
- Signal generated after a peer disconnects. If they don't reconnect they will be removed.
-
-
-
-
-
- Signal generated after a peer joins the lobby.
-
-
-
-
-
-
- Signal generated after a peer leaves the lobby.
-
-
-
-
-
-
- Signal generated after a peer sends a chat message.
-
-
-
-
-
-
- Signal generated after a peer is ready.
-
-
-
-
-
- Signal generated after a peer reconnects.
-
-
-
-
-
- Signal generated after data is sent to the lobby.
-
-
-
-
-
-
-
- Signal generated after data is sent to peer.
-
-
-
-
-
-
- Signal generated after user data is sent to peer.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/AuthoritativeLobbyResponse.xml b/modules/blazium_sdk/doc_classes/AuthoritativeLobbyResponse.xml
deleted file mode 100644
index 065c683f5e8a..000000000000
--- a/modules/blazium_sdk/doc_classes/AuthoritativeLobbyResponse.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Response from a [method AuthoritativeLobbyClient.lobby_call] call.
-
-
- Response from a [method AuthoritativeLobbyClient.lobby_call] call. Await on [signal finished] signal to get the [AuthoritativeLobbyResult].
-
-
-
-
-
-
-
- Signal emitted when the request is finished.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/AuthoritativeLobbyResult.xml b/modules/blazium_sdk/doc_classes/AuthoritativeLobbyResult.xml
deleted file mode 100644
index a648755a74de..000000000000
--- a/modules/blazium_sdk/doc_classes/AuthoritativeLobbyResult.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- A result from a [AuthoritativeLobbyResponse].
-
-
- A result from a [AuthoritativeLobbyResponse]. Contains either result or error.
-
-
-
-
-
-
-
- Result of the function call.
-
-
-
-
-
- Returns true if there is an error.
-
-
-
-
-
- Gets the error message.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/BlaziumClient.xml b/modules/blazium_sdk/doc_classes/BlaziumClient.xml
deleted file mode 100644
index 2df6d3e3dc0c..000000000000
--- a/modules/blazium_sdk/doc_classes/BlaziumClient.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- Base node for connecting to the Blazium services.
-
-
- The [BlaziumClient] node provides an interface for connecting to the Blazium services. These services are designed to simplify game development with aspects such as multiplayer, authentication, etc.
- Developers have the flexibility to either:
- - Connect to the free Blazium services hosted on the [url=https://blazium.app]blazium.app[/url] domain.
- - Self-deploy the Blazium services on their own infrastructure for full control and customization.
- [codeblock lang=text]
-
- +---------------------+ +---------------------+
- | Blazium Engine | HTTP and | Blazium Service |
- |---------------------| WebSocket |---------------------|
- | - Send requests | <---------> | - Handle requests |
- | - Receive responses | | - Send responses |
- +---------------------+ +---------------------+
-
- [/codeblock]
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/GameServerInfo.xml b/modules/blazium_sdk/doc_classes/GameServerInfo.xml
deleted file mode 100644
index 73b660c951dd..000000000000
--- a/modules/blazium_sdk/doc_classes/GameServerInfo.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
- Game server info used by the [MasterServerClient].
-
-
- Game server info used by the [MasterServerClient]. Used to [method MasterServerClient.create_game] or [method MasterServerClient.update_game].
-
-
-
-
-
- Description of the game server.
-
-
- Name of the game server.
-
-
- Id of the game server. Generated after call to [method MasterServerClient.create_game].
-
-
- Ip address of the game server.
-
-
- Max players of the game server.
-
-
- Players of the game server.
-
-
- Port of the game server.
-
-
- Version of the game server.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/ListLobbyResponse.xml b/modules/blazium_sdk/doc_classes/ListLobbyResponse.xml
deleted file mode 100644
index 74f319244ffc..000000000000
--- a/modules/blazium_sdk/doc_classes/ListLobbyResponse.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Response from a [method LobbyClient.list_lobbies] call.
-
-
- Response from a [method LobbyClient.list_lobbies] call. Await on [signal finished] signal to get the [ListLobbyResult].
-
-
-
-
-
-
-
- Signal emitted when the request is finished.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/ListLobbyResult.xml b/modules/blazium_sdk/doc_classes/ListLobbyResult.xml
deleted file mode 100644
index e87b0b173ee4..000000000000
--- a/modules/blazium_sdk/doc_classes/ListLobbyResult.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- A result from a [ListLobbyResponse].
-
-
- A result from a [ListLobbyResponse]. Contains either result or error.
-
-
-
-
-
-
-
- Returns true if there is an error.
-
-
-
-
-
- Gets the error message.
-
-
- Gets the lobbies.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/LobbyClient.xml b/modules/blazium_sdk/doc_classes/LobbyClient.xml
deleted file mode 100644
index 9a86a7749585..000000000000
--- a/modules/blazium_sdk/doc_classes/LobbyClient.xml
+++ /dev/null
@@ -1,391 +0,0 @@
-
-
-
- Node for connecting to the Blazium Lobby service. Offers non-authoritative lobby making features.
-
-
- The [LobbyClient] node provides an interface for connecting to the Blazium Lobby 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.
- - [member host_data]: The current lobby private data. Only works if you are host.
- - [member peer_data]: The current peer private data.
-
-
- https://github.com/blazium-engine/blazium-lobby-sdk
-
-
-
-
-
-
-
- Add data 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 received_lobby_data].
-
-
-
-
-
-
- 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].
-
-
-
-
-
-
-
-
- Add data to a peer. Only works if you are host.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal received_peer_data].
-
-
-
-
-
-
- Add user data to your own peer.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal received_peer_user_data].
-
-
-
-
-
-
-
- Add data to all peers. Only works if you are host.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal received_peer_data].
-
-
-
-
-
- Connect to a Blazium Lobby Server using the [member game_id] and [member server_url].
- Generates [signal connected_to_lobby] signal if successful.
-
-
-
-
-
-
-
-
-
- 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.
-
-
-
-
-
-
-
- Delete one or more keys from the lobby data. Only works if you are host.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal received_lobby_data].
-
-
-
-
-
-
- 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].
-
-
-
-
-
-
-
-
- Delete one or more keys from the peer data. Only works if you are host.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal received_peer_data].
-
-
-
-
-
-
- Delete one or more keys from the peers user data.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal received_peer_user_data].
-
-
-
-
-
-
-
- Delete one or more keys from the peers data. Only works if you are host.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal received_peer_data].
-
-
-
-
-
- Disconnect from the lobby server.
- Generates [signal disconnected_from_lobby] signal.
-
-
-
-
-
- Returns true if you are the host of the current lobby.
-
-
-
-
-
-
-
- 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].
-
-
-
-
-
-
- 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.
-
-
-
-
-
- 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].
-
-
-
-
-
-
-
-
- Lists all lobbies. Lobbies that are sealed won't show in the list, except if you disconnected and trying to reconnect to a lobby.
-
-
-
-
-
-
- Send a notification either to the host, or if you are host send data to all peers.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal lobby_notified] signal.
-
-
-
-
-
-
-
- Send a notification to a peer, works only if you are host.
- Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished.
- Generates [signal lobby_notified] signal.
-
-
-
-
-
-
- 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].
-
-
-
-
-
-
- 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].
-
-
-
-
-
-
- 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].
-
-
-
-
-
- True if the client is connected, else false.
-
-
- The game id.
-
-
- The current lobby private data. Only works if you are host.
-
-
- The current lobby. Reflects changes to the lobby.
-
-
- The current peer. Reflects changes to the self peer.
-
-
- The current peer private data.
-
-
- The lobby peers. Reflects changes to all peers.
-
-
- Reconnection token.
-
-
- Set to what url this lobby should connect to.
-
-
-
-
-
-
-
- Signal generated after you connect to the lobby.
-
-
-
-
-
- Signal generated after you disconnect from the lobby.
-
-
-
-
-
-
- Signal generated after a lobby is created.
-
-
-
-
-
-
- Signal generated after you joint a lobby.
-
-
-
-
-
- Signal generated after you leave a lobby.
-
-
-
-
-
-
- Signal generated after a notification is received.
-
-
-
-
-
- Signal generated after the host seals the lobby.
-
-
-
-
-
- Signal generated after the host updated the tags of the lobby
-
-
-
-
-
-
- Signals a log from a command.
-
-
-
-
-
- Signal generated after a peer disconnects. If they don't reconnect they will be removed.
-
-
-
-
-
- Signal generated after a peer joins the lobby.
-
-
-
-
-
-
- Signal generated after a peer leaves the lobby.
-
-
-
-
-
-
- Signal generated after a peer sends a chat message.
-
-
-
-
-
-
- Signal generated after a peer is ready.
-
-
-
-
-
- Signal generated after a peer reconnects.
-
-
-
-
-
-
- Signal generated after data is sent to the lobby.
-
-
-
-
-
-
-
- Signal generated after data is sent to peer.
-
-
-
-
-
-
- Signal generated after user data is sent to peer.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/LobbyInfo.xml b/modules/blazium_sdk/doc_classes/LobbyInfo.xml
deleted file mode 100644
index 5d2310a8952c..000000000000
--- a/modules/blazium_sdk/doc_classes/LobbyInfo.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
- Lobby information returned after a [LobbyClient] request that returns a lobby.
-
-
- Lobby information returned after a [LobbyClient] request that returns a lobby.
-
-
-
-
-
- The lobby public data.
-
-
- The host id of the lobby.
-
-
- The id of the lobby.
-
-
- The name of the lobby.
-
-
- The maximum number of players allowed in the lobby. 0 = unlimited
-
-
- Whether the lobby is password protected.
-
-
- The number of players currently in the lobby.
-
-
- Whether the lobby is sealed.
-
-
- The tags of the lobby. Used for listing lobbies to filter based on them.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/LobbyPeer.xml b/modules/blazium_sdk/doc_classes/LobbyPeer.xml
deleted file mode 100644
index cb4a491f5c82..000000000000
--- a/modules/blazium_sdk/doc_classes/LobbyPeer.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- Lobby information returned after a [LobbyClient] request that returns peers.
-
-
- Lobby information returned after a [LobbyClient] request that returns peers.
-
-
-
-
-
- Public data of the peer.
-
-
- Identifier of the peer.
-
-
- Whether the peer is ready.
-
-
- Public user data of the peer.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/LobbyResponse.xml b/modules/blazium_sdk/doc_classes/LobbyResponse.xml
deleted file mode 100644
index 2a71c66f7e50..000000000000
--- a/modules/blazium_sdk/doc_classes/LobbyResponse.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Generic response from a [LobbyClient] call.
-
-
- Generic response from a [LobbyClient] call. Await on [signal finished] signal to get the [LobbyResult].
-
-
-
-
-
-
-
- Signal emitted when the request is finished.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/LobbyResult.xml b/modules/blazium_sdk/doc_classes/LobbyResult.xml
deleted file mode 100644
index a1bd0450a75f..000000000000
--- a/modules/blazium_sdk/doc_classes/LobbyResult.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- A result from a [LobbyResponse].
-
-
- A result from a [LobbyResponse]. Contains either nothing or error.
-
-
-
-
-
-
-
- Returns true if there is an error.
-
-
-
-
-
- Gets the error message.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/LoginClient.xml b/modules/blazium_sdk/doc_classes/LoginClient.xml
deleted file mode 100644
index 3e4ebe099216..000000000000
--- a/modules/blazium_sdk/doc_classes/LoginClient.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
- Node for connecting to the Blazium Login service. Offers authentication mechanism.
-
-
- The [LoginClient] node provides an interface for connecting to the Blazium Login service. There is a free instance hosted on the [url=https://blazium.app]blazium.app[/url] domain that is used by default.
- The authentication flow is as follows:
- 1. Listen to all the signals you are interested in.
- 2. Connect to the server using the [method connect_to_server] method.
- 3. Then you can request login info using the [method request_login_info] method.
- 4. Open the resulting login url received after awaiting on the [signal LoginResponse.finished] signal.
- 5. Obtain the jwt from the [signal received_jwt] signal.
- [b]Note:[/b] Some methods are non blocking and can be awaited in order to get the result.
-
-
-
-
-
-
-
- Connects to the server specified in [member server_url] using the game id specified in [member game_id]. Must be done before requesting login info.
- Generates [signal connected_to_server] when connected.
-
-
-
-
-
- Disconnect from the server.
- Generates [signal disconnected_from_server] when disconnected.
-
-
-
-
-
-
- Request login info using the login type specified.
- Returns a [LoginResponse] object that has a [signal LoginResponse.finished] signal that is emitted when finished.
-
-
-
-
-
- Client connected state.
-
-
- Set what game id this client should use when connecting to the server. If this is missing connection will error.
- Can only contain alphanumeric characters.
-
-
- Set to what url this client should connect to.
-
-
-
-
-
- Signal emitted when the client connects to the server.
-
-
-
-
-
- Signal emitted when the client disconnects from the server.
-
-
-
-
-
-
- Signals a log from a command.
-
-
-
-
-
-
- Signal emitted when a JWT is received.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/LoginResponse.xml b/modules/blazium_sdk/doc_classes/LoginResponse.xml
deleted file mode 100644
index e8253ce6a0af..000000000000
--- a/modules/blazium_sdk/doc_classes/LoginResponse.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Response from a [method LoginClient.request_login_info] call.
-
-
- Response from a [method LoginClient.request_login_info] call. Await on [signal finished] signal to get the [LoginResult].
-
-
-
-
-
-
-
- Signal emitted when the request is finished.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/LoginResult.xml b/modules/blazium_sdk/doc_classes/LoginResult.xml
deleted file mode 100644
index 2551db3606a4..000000000000
--- a/modules/blazium_sdk/doc_classes/LoginResult.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- A result from a [LoginResponse].
-
-
- A result from a [LoginResponse]. Contains either result or error.
-
-
-
-
-
-
-
- Returns true if there is an error.
-
-
-
-
-
- The error message.
-
-
- The login type.
-
-
- The login url.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/MasterServerClient.xml b/modules/blazium_sdk/doc_classes/MasterServerClient.xml
deleted file mode 100644
index 7e4544a3be06..000000000000
--- a/modules/blazium_sdk/doc_classes/MasterServerClient.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
- Node for connecting to the Blazium Master Server service. Offers a centralized location for game server association.
-
-
- The [MasterServerClient] node provides an interface for connecting to the Blazium Master Server service. There is a free instance hosted on the [url=https://blazium.app]blazium.app[/url] domain that is used by default.
- [b]Note:[/b] All methods are non blocking and can be awaited in order to get the result.
-
-
-
-
-
-
-
-
- Create a game server.
- Returns a [MasterServerResponse] object that has a [signal MasterServerResponse.finished] signal that is emitted when finished.
-
-
-
-
-
- Get a list of recent games.
- Returns a [MasterServerListResponse] object that has a [signal MasterServerListResponse.finished] signal that is emitted when finished.
-
-
-
-
-
-
- Update a game server.
- Returns a [MasterServerResponse] object that has a [signal MasterServerResponse.finished] signal that is emitted when finished.
-
-
-
-
-
- Set what game id this client should use when connecting to the server. If this is missing connection will error.
- Can only contain alphanumeric characters.
-
-
- Set to what url this client should connect to.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/MasterServerListResponse.xml b/modules/blazium_sdk/doc_classes/MasterServerListResponse.xml
deleted file mode 100644
index 33fcc0b5de1a..000000000000
--- a/modules/blazium_sdk/doc_classes/MasterServerListResponse.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Response from a [method MasterServerClient.recent_games] call.
-
-
- Response from a [method MasterServerClient.recent_games] call. Await on [signal finished] signal to get the [MasterServerListResult].
-
-
-
-
-
-
-
- Signal emitted when the request is finished.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/MasterServerListResult.xml b/modules/blazium_sdk/doc_classes/MasterServerListResult.xml
deleted file mode 100644
index a4a8ed91c2e3..000000000000
--- a/modules/blazium_sdk/doc_classes/MasterServerListResult.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- A result from a [MasterServerListResponse].
-
-
- A result from a [MasterServerListResponse]. Contains either result or error.
-
-
-
-
-
-
-
- Returns true if there is an error.
-
-
-
-
-
- The error message.
-
-
- The results.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/MasterServerResponse.xml b/modules/blazium_sdk/doc_classes/MasterServerResponse.xml
deleted file mode 100644
index 6bb73599f10f..000000000000
--- a/modules/blazium_sdk/doc_classes/MasterServerResponse.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Response from a [method MasterServerClient.create_game] or [method MasterServerClient.update_game] call.
-
-
- Response from a [method MasterServerClient.create_game] or [method MasterServerClient.update_game] call. Await on [signal finished] signal to get the [MasterServerResult].
-
-
-
-
-
-
-
- Signal emitted when the request is finished.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/MasterServerResult.xml b/modules/blazium_sdk/doc_classes/MasterServerResult.xml
deleted file mode 100644
index b79de2e983fc..000000000000
--- a/modules/blazium_sdk/doc_classes/MasterServerResult.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- A result from a [MasterServerResponse].
-
-
- A result from a [MasterServerResponse]. Contains either result or error.
-
-
-
-
-
-
-
- Returns true if there is an error.
-
-
-
-
-
- Gets the error message.
-
-
- Gets the result.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/POGRClient.xml b/modules/blazium_sdk/doc_classes/POGRClient.xml
deleted file mode 100644
index 2f93948990f9..000000000000
--- a/modules/blazium_sdk/doc_classes/POGRClient.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
- Node for connecting to the POGR analytics service.
-
-
- The [POGRClient] node provides an interface for connecting to the POGR analytics service. Find out more on the [url=https://pogr.gg]pogr.gg[/url] website.
- The normal flow is as follows:
- 1. Initiate a session using [method init] method.
- 2. Send data using [method data], [method event], [method logs], [method metrics] and [method monitor] methods, depending on use case.
- 3. Close the session using [method end] method at the end of the game.
- [b]Note:[/b] All methods are non blocking and can be awaited in order to get the result.
-
-
-
-
-
-
-
-
- Send unstructured data.
- Returns a [POGRResponse] object that has a [signal POGRResponse.finished] signal that is emitted when finished.
-
-
-
-
-
- Send end request.
- Returns a [POGRResponse] object that has a [signal POGRResponse.finished] signal that is emitted when finished.
-
-
-
-
-
-
-
-
-
-
-
- Send event with unstructured data.
- Returns a [POGRResponse] object that has a [signal POGRResponse.finished] signal that is emitted when finished.
-
-
-
-
-
- Get the build id.
-
-
-
-
-
- Get the client id.
-
-
-
-
-
- Get the pogr url.
-
-
-
-
-
- Get the session id. This is a unique identifier for the current session generated after [method init] is called.
-
-
-
-
-
- Send init request. Needs to be called first.
- Returns a [POGRResponse] object that has a [signal POGRResponse.finished] signal that is emitted when finished.
-
-
-
-
-
-
-
-
-
-
-
-
- Add logs to the analytics.
- Returns a [POGRResponse] object that has a [signal POGRResponse.finished] signal that is emitted when finished.
-
-
-
-
-
-
-
-
-
- Add metrics to the analytics.
- Returns a [POGRResponse] object that has a [signal POGRResponse.finished] signal that is emitted when finished.
-
-
-
-
-
-
- Send monitor request.
- Returns a [POGRResponse] object that has a [signal POGRResponse.finished] signal that is emitted when finished.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/POGRResponse.xml b/modules/blazium_sdk/doc_classes/POGRResponse.xml
deleted file mode 100644
index 3227a66f1bb4..000000000000
--- a/modules/blazium_sdk/doc_classes/POGRResponse.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Response from a [POGRClient] call.
-
-
- Response from a [POGRClient] call. Await on [signal finished] signal to get the [POGRResult].
-
-
-
-
-
-
-
- Signal emitted when the request is finished.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/POGRResult.xml b/modules/blazium_sdk/doc_classes/POGRResult.xml
deleted file mode 100644
index 5a983cb63530..000000000000
--- a/modules/blazium_sdk/doc_classes/POGRResult.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- A result from a [POGRResponse].
-
-
- A result from a [POGRResponse]. Contains either result or error.
-
-
-
-
-
-
-
- Returns true if there is an error.
-
-
-
-
-
- The error message.
-
-
- The result.
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/ViewLobbyResponse.xml b/modules/blazium_sdk/doc_classes/ViewLobbyResponse.xml
deleted file mode 100644
index cd468022fa15..000000000000
--- a/modules/blazium_sdk/doc_classes/ViewLobbyResponse.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Response from a [LobbyClient] call.
-
-
- Response from a [LobbyClient] call. Await on [signal finished] signal to get the [ViewLobbyResult].
-
-
-
-
-
-
-
- Signal emitted when the request is finished.
-
-
-
-
diff --git a/modules/blazium_sdk/doc_classes/ViewLobbyResult.xml b/modules/blazium_sdk/doc_classes/ViewLobbyResult.xml
deleted file mode 100644
index a5934ebff323..000000000000
--- a/modules/blazium_sdk/doc_classes/ViewLobbyResult.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- A result from a [ViewLobbyResponse].
-
-
- A result from a [ViewLobbyResponse]. Contains either result or error.
-
-
-
-
-
-
-
- Returns true if there is an error.
-
-
-
-
-
- Gets the error message.
-
-
- Gets the lobby.
-
-
- Gets the peers.
-
-
-
diff --git a/modules/blazium_sdk/icons/AuthoritativeLobbyClient.svg b/modules/blazium_sdk/icons/AuthoritativeLobbyClient.svg
deleted file mode 100644
index a64229e346ce..000000000000
--- a/modules/blazium_sdk/icons/AuthoritativeLobbyClient.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/modules/blazium_sdk/icons/BlaziumClient.svg b/modules/blazium_sdk/icons/BlaziumClient.svg
deleted file mode 100644
index e000cd5827ab..000000000000
--- a/modules/blazium_sdk/icons/BlaziumClient.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/modules/blazium_sdk/icons/LobbyClient.svg b/modules/blazium_sdk/icons/LobbyClient.svg
deleted file mode 100644
index d208bca7ab2a..000000000000
--- a/modules/blazium_sdk/icons/LobbyClient.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/modules/blazium_sdk/icons/LoginClient.svg b/modules/blazium_sdk/icons/LoginClient.svg
deleted file mode 100644
index d304a6c8d5ae..000000000000
--- a/modules/blazium_sdk/icons/LoginClient.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/modules/blazium_sdk/icons/MasterServerClient.svg b/modules/blazium_sdk/icons/MasterServerClient.svg
deleted file mode 100644
index df4b6d512d80..000000000000
--- a/modules/blazium_sdk/icons/MasterServerClient.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/modules/blazium_sdk/icons/POGRClient.svg b/modules/blazium_sdk/icons/POGRClient.svg
deleted file mode 100644
index b558dcb5974b..000000000000
--- a/modules/blazium_sdk/icons/POGRClient.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp b/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp
deleted file mode 100644
index 8ffccc8c1eb1..000000000000
--- a/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp
+++ /dev/null
@@ -1,790 +0,0 @@
-/**************************************************************************/
-/* authoritative_lobby_client.cpp */
-/**************************************************************************/
-/* This file is part of: */
-/* BLAZIUM ENGINE */
-/* https://blazium.app */
-/**************************************************************************/
-/* Copyright (c) 2024-present Blazium Engine contributors. */
-/* Copyright (c) 2024 Dragos Daian, Randolph William Aarseth II. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#include "./authoritative_lobby_client.h"
-#include "./lobby_client.h"
-#include "lobby_info.h"
-#include "scene/main/node.h"
-AuthoritativeLobbyClient::AuthoritativeLobbyClient() {
- lobby.instantiate();
- peer.instantiate();
- _socket = Ref(WebSocketPeer::create());
- set_process_internal(false);
-}
-
-AuthoritativeLobbyClient::~AuthoritativeLobbyClient() {
- _socket->close();
- set_process_internal(false);
-}
-
-void AuthoritativeLobbyClient::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_server_url", "server_url"), &AuthoritativeLobbyClient::set_server_url);
- ClassDB::bind_method(D_METHOD("get_server_url"), &AuthoritativeLobbyClient::get_server_url);
- ClassDB::bind_method(D_METHOD("set_reconnection_token", "reconnection_token"), &AuthoritativeLobbyClient::set_reconnection_token);
- ClassDB::bind_method(D_METHOD("get_reconnection_token"), &AuthoritativeLobbyClient::get_reconnection_token);
- ClassDB::bind_method(D_METHOD("set_game_id", "game_id"), &AuthoritativeLobbyClient::set_game_id);
- ClassDB::bind_method(D_METHOD("get_game_id"), &AuthoritativeLobbyClient::get_game_id);
-
- ClassDB::bind_method(D_METHOD("is_host"), &AuthoritativeLobbyClient::is_host);
- ClassDB::bind_method(D_METHOD("get_connected"), &AuthoritativeLobbyClient::get_connected);
- ClassDB::bind_method(D_METHOD("get_lobby"), &AuthoritativeLobbyClient::get_lobby);
- ClassDB::bind_method(D_METHOD("get_peer"), &AuthoritativeLobbyClient::get_peer);
- ClassDB::bind_method(D_METHOD("get_peers"), &AuthoritativeLobbyClient::get_peers);
- ClassDB::bind_method(D_METHOD("get_peer_data"), &AuthoritativeLobbyClient::get_peer_data);
-
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "server_url", PROPERTY_HINT_NONE, ""), "set_server_url", "get_server_url");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "reconnection_token", PROPERTY_HINT_NONE, ""), "set_reconnection_token", "get_reconnection_token");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "game_id", PROPERTY_HINT_NONE, ""), "set_game_id", "get_game_id");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "connected"), "", "get_connected");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "lobby", PROPERTY_HINT_RESOURCE_TYPE, "LobbyInfo"), "", "get_lobby");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), "", "get_peer");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "peers", PROPERTY_HINT_ARRAY_TYPE, "LobbyPeer"), "", "get_peers");
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "peer_data"), "", "get_peer_data");
- ADD_PROPERTY_DEFAULT("peers", TypedArray());
- ADD_PROPERTY_DEFAULT("peer", Ref());
- ADD_PROPERTY_DEFAULT("lobby", Ref());
- // Register methods
- ClassDB::bind_method(D_METHOD("connect_to_lobby"), &AuthoritativeLobbyClient::connect_to_lobby);
- ClassDB::bind_method(D_METHOD("disconnect_from_lobby"), &AuthoritativeLobbyClient::disconnect_from_lobby);
- ClassDB::bind_method(D_METHOD("create_lobby", "title", "tags", "max_players", "password"), &AuthoritativeLobbyClient::create_lobby, DEFVAL(Dictionary()), DEFVAL(4), DEFVAL(""));
- ClassDB::bind_method(D_METHOD("join_lobby", "lobby_id", "password"), &AuthoritativeLobbyClient::join_lobby, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("leave_lobby"), &AuthoritativeLobbyClient::leave_lobby);
- ClassDB::bind_method(D_METHOD("lobby_call", "method", "args"), &AuthoritativeLobbyClient::lobby_call, DEFVAL(Array()));
- ClassDB::bind_method(D_METHOD("list_lobbies", "tags", "start", "count"), &AuthoritativeLobbyClient::list_lobby, DEFVAL(Dictionary()), DEFVAL(0), DEFVAL(10));
- ClassDB::bind_method(D_METHOD("kick_peer", "peer_id"), &AuthoritativeLobbyClient::kick_peer);
- ClassDB::bind_method(D_METHOD("send_chat_message", "chat_message"), &AuthoritativeLobbyClient::lobby_chat);
- ClassDB::bind_method(D_METHOD("set_lobby_ready", "ready"), &AuthoritativeLobbyClient::lobby_ready);
- ClassDB::bind_method(D_METHOD("add_lobby_tags", "tags"), &AuthoritativeLobbyClient::set_lobby_tags);
- ClassDB::bind_method(D_METHOD("del_lobby_tags", "keys"), &AuthoritativeLobbyClient::del_lobby_tags);
- ClassDB::bind_method(D_METHOD("set_lobby_sealed", "seal"), &AuthoritativeLobbyClient::seal_lobby);
- ClassDB::bind_method(D_METHOD("add_peer_user_data", "data"), &AuthoritativeLobbyClient::add_user_data);
- ClassDB::bind_method(D_METHOD("del_peer_user_data", "keys"), &AuthoritativeLobbyClient::del_user_data);
-
- // Register signals
- ADD_SIGNAL(MethodInfo("connected_to_lobby", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::STRING, "reconnection_token")));
- ADD_SIGNAL(MethodInfo("disconnected_from_lobby", PropertyInfo(Variant::STRING, "reason")));
- ADD_SIGNAL(MethodInfo("received_peer_user_data", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::OBJECT, "data")));
- ADD_SIGNAL(MethodInfo("lobby_notified", PropertyInfo(Variant::OBJECT, "data")));
- ADD_SIGNAL(MethodInfo("received_peer_data", PropertyInfo(Variant::OBJECT, "data"), PropertyInfo(Variant::OBJECT, "to_peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::BOOL, "is_private")));
- ADD_SIGNAL(MethodInfo("received_lobby_data", PropertyInfo(Variant::OBJECT, "data")));
- ADD_SIGNAL(MethodInfo("lobby_created", PropertyInfo(Variant::OBJECT, "lobby", PROPERTY_HINT_RESOURCE_TYPE, "LobbyInfo"), PropertyInfo(Variant::ARRAY, "peers", PROPERTY_HINT_ARRAY_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("lobby_joined", PropertyInfo(Variant::OBJECT, "lobby", PROPERTY_HINT_RESOURCE_TYPE, "LobbyInfo"), PropertyInfo(Variant::ARRAY, "peers", PROPERTY_HINT_ARRAY_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("lobby_left", PropertyInfo(Variant::BOOL, "kicked")));
- ADD_SIGNAL(MethodInfo("lobby_sealed", PropertyInfo(Variant::BOOL, "sealed")));
- ADD_SIGNAL(MethodInfo("lobby_tagged", PropertyInfo(Variant::DICTIONARY, "tags")));
- ADD_SIGNAL(MethodInfo("peer_joined", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("peer_reconnected", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("peer_left", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::BOOL, "kicked")));
- ADD_SIGNAL(MethodInfo("peer_disconnected", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("peer_messaged", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::STRING, "chat_message")));
- ADD_SIGNAL(MethodInfo("peer_ready", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::BOOL, "is_ready")));
- ADD_SIGNAL(MethodInfo("log_updated", PropertyInfo(Variant::STRING, "command"), PropertyInfo(Variant::STRING, "logs")));
-}
-
-void AuthoritativeLobbyClient::set_server_url(const String &p_server_url) { this->server_url = p_server_url; }
-String AuthoritativeLobbyClient::get_server_url() { return server_url; }
-void AuthoritativeLobbyClient::set_reconnection_token(const String &p_reconnection_token) { this->reconnection_token = p_reconnection_token; }
-String AuthoritativeLobbyClient::get_reconnection_token() { return reconnection_token; }
-void AuthoritativeLobbyClient::set_game_id(const String &p_game_id) { this->game_id = p_game_id; }
-String AuthoritativeLobbyClient::get_game_id() { return game_id; }
-bool AuthoritativeLobbyClient::is_host() { return lobby->get_host() == peer->get_id(); }
-bool AuthoritativeLobbyClient::get_connected() { return connected; }
-void AuthoritativeLobbyClient::set_lobby(const Ref &p_lobby) { this->lobby = p_lobby; }
-Ref AuthoritativeLobbyClient::get_lobby() { return lobby; }
-void AuthoritativeLobbyClient::set_peer(const Ref &p_peer) { this->peer = p_peer; }
-Ref AuthoritativeLobbyClient::get_peer() { return peer; }
-TypedArray AuthoritativeLobbyClient::get_peers() { return peers; }
-Dictionary AuthoritativeLobbyClient::get_peer_data() { return peer_data; }
-
-bool AuthoritativeLobbyClient::connect_to_lobby() {
- if (connected) {
- return true;
- }
- String lobby_url = get_server_url();
- String url = lobby_url;
- PackedStringArray protocols;
- protocols.push_back("blazium");
- protocols.push_back(game_id);
- if (reconnection_token != "") {
- protocols.push_back(reconnection_token);
- }
- _socket->set_supported_protocols(protocols);
- Error err = _socket->connect_to_url(url);
- if (err != OK) {
- set_process_internal(false);
- emit_signal("log_updated", "error", "Unable to connect to lobby server at: " + url);
- connected = false;
- return false;
- }
- set_process_internal(true);
- emit_signal("log_updated", "connect_to_lobby", "Connecting to: " + url);
- return true;
-}
-
-void AuthoritativeLobbyClient::disconnect_from_lobby() {
- if (connected) {
- _socket->close(1000, "Normal Closure");
- connected = false;
- peer->set_data(Dictionary());
- peers.clear();
- lobby->set_dict(Dictionary());
- peer_data = Dictionary();
- set_process_internal(false);
- emit_signal("disconnected_from_lobby", _socket->get_close_reason());
- emit_signal("log_updated", "disconnect_from_lobby", "Disconnected from: " + get_server_url());
- }
-}
-
-String AuthoritativeLobbyClient::_increment_counter() {
- return String::num(_counter++);
-}
-
-Ref AuthoritativeLobbyClient::create_lobby(const String &p_name, const Dictionary &p_tags, int p_max_players, const String &p_password) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "create_lobby";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["name"] = p_name;
- data_dict["max_players"] = p_max_players;
- data_dict["password"] = p_password;
- data_dict["tags"] = p_tags;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_VIEW);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::join_lobby(const String &p_lobby_id, const String &p_password) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "join_lobby";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["lobby_id"] = p_lobby_id;
- data_dict["password"] = p_password;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_VIEW);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::lobby_call(const String &p_method, const Array &p_args) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "lobby_call";
- Dictionary data_dict;
- data_dict["function"] = p_method;
- data_dict["inputs"] = p_args;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_CALL);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::leave_lobby() {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "leave_lobby";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::list_lobby(const Dictionary &p_tags, int p_start, int p_count) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "list_lobby";
- Dictionary data_dict;
- data_dict["id"] = id;
- data_dict["start"] = p_start;
- data_dict["count"] = p_count;
- Dictionary filter_dict;
- data_dict["filter"] = filter_dict;
- if (p_tags.size() != 0) {
- filter_dict["tags"] = p_tags;
- }
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_LIST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::kick_peer(const String &p_peer_id) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "kick_peer";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["peer_id"] = p_peer_id;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::add_user_data(const Dictionary &p_user_data) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "user_data";
- Dictionary data_dict;
- data_dict["user_data"] = p_user_data;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::del_user_data(const TypedArray &p_keys) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "user_data";
- Dictionary data_dict;
- Dictionary data_object_dict;
- data_dict["user_data"] = data_object_dict;
- // set null value
- for (int i = 0; i < p_keys.size(); i++) {
- data_object_dict[p_keys[i]] = Variant();
- }
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::set_lobby_tags(const Dictionary &p_tags) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "lobby_tags";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["tags"] = p_tags;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::del_lobby_tags(const TypedArray &p_keys) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "lobby_tags";
- Dictionary data_dict;
- command["data"] = data_dict;
- Dictionary data_object_dict;
- // set null value
- for (int i = 0; i < p_keys.size(); i++) {
- data_object_dict[p_keys[i]] = Variant();
- }
- data_dict["tags"] = data_object_dict;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::lobby_chat(const String &p_chat_message) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "chat_lobby";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["chat"] = p_chat_message;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::lobby_ready(bool p_ready) {
- String id = _increment_counter();
- Dictionary command;
- if (p_ready) {
- command["command"] = "lobby_ready";
- } else {
- command["command"] = "lobby_unready";
- }
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref AuthoritativeLobbyClient::seal_lobby(bool seal) {
- String id = _increment_counter();
- Dictionary command;
- if (seal) {
- command["command"] = "seal_lobby";
- } else {
- command["command"] = "unseal_lobby";
- }
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-void AuthoritativeLobbyClient::_notification(int p_what) {
- switch (p_what) {
- case NOTIFICATION_INTERNAL_PROCESS: {
- _socket->poll();
-
- WebSocketPeer::State state = _socket->get_ready_state();
- if (state == WebSocketPeer::STATE_OPEN) {
- if (!connected) {
- connected = true;
- emit_signal("log_updated", "connect_to_lobby", "Connected to: " + server_url);
- }
- while (_socket->get_available_packet_count() > 0) {
- Vector packet_buffer;
- Error err = _socket->get_packet_buffer(packet_buffer);
- if (err != OK) {
- emit_signal("log_updated", "error", "Unable to get packet.");
- return;
- }
- String packet_string = String::utf8((const char *)packet_buffer.ptr(), packet_buffer.size());
- _receive_data(JSON::parse_string(packet_string));
- }
- } else if (state == WebSocketPeer::STATE_CLOSED) {
- emit_signal("log_updated", "error", _socket->get_close_reason());
- emit_signal("disconnected_from_lobby", _socket->get_close_reason());
- set_process_internal(false);
- connected = false;
- }
- } break;
- }
-}
-
-void AuthoritativeLobbyClient::_send_data(const Dictionary &p_data_dict) {
- if (_socket->get_ready_state() != WebSocketPeer::STATE_OPEN) {
- emit_signal("log_updated", "error", "Socket is not ready.");
- return;
- }
- Error err = _socket->send_text(JSON::stringify(p_data_dict));
- if (err != OK) {
- emit_signal("log_updated", "error", "No longer connected.");
- _socket->close(1000, "Disconnected");
- }
-}
-
-void AuthoritativeLobbyClient::_update_peers(Dictionary p_data_dict, TypedArray &p_peers) {
- Array peers_array = p_data_dict.get("peers", Array());
- TypedArray peers_info;
- p_peers.clear();
- for (int i = 0; i < peers_array.size(); ++i) {
- Ref peer_info = Ref(memnew(LobbyPeer));
- Dictionary peer_dict = peers_array[i];
- peer_info->set_dict(peer_dict);
- if (peer_dict.has("private_data")) {
- peer_data = peer_dict.get("private_data", Dictionary());
- }
- p_peers.push_back(peer_info);
- }
-}
-
-void AuthoritativeLobbyClient::_clear_lobby() {
- lobby->set_dict(Dictionary());
- peers.clear();
- peer->set_data(Dictionary());
- peer->set_ready(false);
- peer_data = Dictionary();
-}
-
-void AuthoritativeLobbyClient::_receive_data(const Dictionary &p_dict) {
- String command = p_dict.get("command", "error");
- String message = p_dict.get("message", "");
- Dictionary data_dict = p_dict.get("data", Dictionary());
- String message_id = data_dict.get("id", "");
- Array command_array = _commands.get(message_id, Array());
- _commands.erase(message_id);
- // update lobby and peers
- {
- TypedArray peers_info;
- if (data_dict.has("peers")) {
- // Iterate through peers and populate arrays
- _update_peers(data_dict, peers_info);
- sort_peers_by_id(peers_info);
- }
- if (data_dict.has("lobby")) {
- Dictionary lobby_dict = data_dict.get("lobby", Dictionary());
- Ref lobby_info = Ref(memnew(LobbyInfo));
- lobby_info->set_dict(lobby_dict);
- if (lobby_info->get_id() == lobby->get_id() || command == "lobby_created" || command == "joined_lobby") {
- // Update lobby info because we viewed our own lobby
- lobby->set_dict(lobby_info->get_dict());
- peers = peers_info;
- }
- }
- }
- if (command == "peer_state") {
- Dictionary peer_dict = data_dict.get("peer", Dictionary());
- peer->set_dict(peer_dict);
- reconnection_token = peer_dict.get("reconnection_token", "");
- emit_signal("connected_to_lobby", peer, reconnection_token);
- } else if (command == "lobby_created") {
- emit_signal("lobby_created", lobby, peers);
- } else if (command == "joined_lobby") {
- emit_signal("lobby_joined", lobby, peers);
- } else if (command == "lobby_left") {
- _clear_lobby();
- emit_signal("lobby_left", false);
- } else if (command == "lobby_kicked") {
- _clear_lobby();
- emit_signal("lobby_left", true);
- } else if (command == "lobby_sealed") {
- Dictionary lobby_dict = data_dict.get("lobby", Dictionary());
- lobby->set_sealed(true);
- emit_signal("lobby_sealed", true);
- } else if (command == "lobby_unsealed") {
- lobby->set_sealed(false);
- emit_signal("lobby_sealed", false);
- } else if (command == "lobby_tags") {
- lobby->set_tags(data_dict.get("tags", Dictionary()));
- emit_signal("lobby_tagged", lobby->get_tags());
- } else if (command == "lobby_list") {
- Array arr = data_dict.get("lobbies", Array());
- TypedArray lobbies_input = arr;
- TypedArray lobbies_output;
- for (int i = 0; i < lobbies_input.size(); ++i) {
- Dictionary lobby_dict = lobbies_input[i];
- Ref lobby_info;
- lobby_info.instantiate();
- lobby_info->set_dict(lobby_dict);
-
- lobbies_output.push_back(lobby_info);
- }
- if (command_array.size() == 2) {
- Ref response = command_array[1];
- if (response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_lobbies(lobbies_output);
- response->emit_signal("finished", result);
- }
- }
- } else if (command == "peer_chat") {
- String peer_id = data_dict.get("from_peer", "");
- String chat_data = data_dict.get("chat_data", "");
- for (int i = 0; i < peers.size(); ++i) {
- Ref found_peer = peers[i];
- if (found_peer->get_id() == peer_id) {
- emit_signal("peer_messaged", found_peer, chat_data);
- break;
- }
- }
- } else if (command == "peer_user_data") {
- String peer_id = data_dict.get("peer_id", "");
- Dictionary peer_user_data = data_dict.get("user_data", "");
- if (peer->get_id() == peer_id) {
- peer->set_user_data(peer_user_data);
- // notify self
- emit_signal("received_peer_user_data", peer, peer_user_data);
- } else {
- // another peer got named
- for (int i = 0; i < peers.size(); ++i) {
- Ref updated_peer = peers[i];
- if (updated_peer->get_id() == peer_id) {
- updated_peer->set_user_data(peer_user_data);
- emit_signal("received_peer_user_data", updated_peer, peer_user_data);
- break;
- }
- }
- }
- } else if (command == "peer_ready") {
- String peer_id = data_dict.get("peer_id", "");
- if (peer->get_id() == peer_id) {
- peer->set_ready(true);
- }
- for (int i = 0; i < peers.size(); ++i) {
- Ref updated_peer = peers[i];
- if (updated_peer->get_id() == String(peer_id)) {
- updated_peer->set_ready(true);
- emit_signal("peer_ready", updated_peer, true);
- break;
- }
- }
- } else if (command == "peer_unready") {
- String peer_id = data_dict.get("peer_id", "");
- if (peer->get_id() == peer_id) {
- peer->set_ready(false);
- }
- for (int i = 0; i < peers.size(); ++i) {
- Ref updated_peer = peers[i];
- if (updated_peer->get_id() == String(data_dict.get("peer_id", ""))) {
- updated_peer->set_ready(false);
- emit_signal("peer_ready", updated_peer, false);
- break;
- }
- }
- } else if (command == "peer_joined") {
- Ref joining_peer = Ref(memnew(LobbyPeer));
- Dictionary peer_dict = data_dict.get("peer", Dictionary());
- joining_peer->set_id(peer_dict.get("id", ""));
- joining_peer->set_user_data(peer_dict.get("user_data", ""));
- peers.append(joining_peer);
- sort_peers_by_id(peers);
- lobby->set_players(peers.size());
- emit_signal("peer_joined", joining_peer);
- } else if (command == "peer_reconnected") {
- for (int i = 0; i < peers.size(); ++i) {
- Ref updated_peer = peers[i];
- if (updated_peer->get_id() == String(data_dict.get("peer_id", ""))) {
- emit_signal("peer_reconnected", updated_peer);
- break;
- }
- }
- } else if (command == "peer_left") {
- for (int i = 0; i < peers.size(); ++i) {
- Ref leaving_peer = peers[i];
- if (leaving_peer->get_id() == String(data_dict.get("peer_id", ""))) {
- peers.remove_at(i);
- lobby->set_players(peers.size());
- emit_signal("peer_left", leaving_peer, data_dict.get("kicked", false));
- break;
- }
- }
- sort_peers_by_id(peers);
- } else if (command == "peer_disconnected") {
- for (int i = 0; i < peers.size(); ++i) {
- Ref leaving_peer = peers[i];
- if (leaving_peer->get_id() == String(data_dict.get("peer_id", ""))) {
- peers.remove_at(i);
- lobby->set_players(peers.size());
- emit_signal("peer_disconnected", leaving_peer);
- break;
- }
- }
- sort_peers_by_id(peers);
- } else if (command == "peer_notify") {
- emit_signal("lobby_notified", data_dict.get("peer_data", Variant()));
- } else if (command == "lobby_data") {
- Dictionary lobby_data = data_dict.get("lobby_data", Dictionary());
- lobby->set_data(lobby_data);
- emit_signal("received_lobby_data", lobby_data);
- // nothing for now
- } else if (command == "data_to") {
- String target_peer_id = data_dict.get("target_peer", "");
- bool is_private = data_dict.get("is_private", false);
- Dictionary peer_data_variant = data_dict.get("peer_data", Dictionary());
- for (int i = 0; i < peers.size(); ++i) {
- Ref updated_peer = peers[i];
- if (updated_peer->get_id() == target_peer_id) {
- // got peer data, update it
- if (is_private && target_peer_id == peer->get_id()) {
- // private data, update self
- peer_data = peer_data_variant;
- } else {
- // public peer data
- updated_peer->set_data(peer_data_variant);
- }
- emit_signal("received_peer_data", peer_data_variant, updated_peer, is_private);
- break;
- }
- }
- } else if (command == "lobby_call") {
- if (command_array.size() == 2) {
- Ref response = command_array[1];
- if (response.is_valid()) {
- Ref result = Ref(memnew(AuthoritativeLobbyResponse::AuthoritativeLobbyResult));
- result->set_result(data_dict.get("result", ""));
- response->emit_signal("finished", result);
- }
- }
- } else if (command == "notified_to") {
- String from_peer_id = data_dict.get("from_peer", "");
- for (int i = 0; i < peers.size(); ++i) {
- Ref from_peer = peers[i];
- if (from_peer->get_id() == from_peer_id) {
- emit_signal("lobby_notified", data_dict.get("peer_data", Variant()), from_peer);
- break;
- }
- }
- } else if (command == "data_to_sent") {
- // nothing for now
- } else if (command == "lobby_notify_sent") {
- // nothing for now
- } else if (command == "notify_to_sent") {
- // nothing for now
- } else if (command == "error") {
- if (command_array.size() == 2) {
- int command_type = command_array[0];
- switch (command_type) {
- case LOBBY_REQUEST: {
- Ref lobby_response = command_array[1];
- if (lobby_response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_error(message);
- lobby_response->emit_signal("finished", result);
- }
- } break;
- case LOBBY_LIST: {
- Ref list_response = command_array[1];
- if (list_response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_error(message);
- list_response->emit_signal("finished", result);
- }
- } break;
- case LOBBY_VIEW: {
- Ref view_response = command_array[1];
- if (view_response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_error(message);
- view_response->emit_signal("finished", result);
- }
- } break;
- case LOBBY_CALL: {
- Ref view_response = command_array[1];
- if (view_response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_error(message);
- view_response->emit_signal("finished", result);
- }
- } break;
- default: {
- emit_signal("log_updated", "error", p_dict["message"]);
- } break;
- }
- }
- } else {
- emit_signal("log_updated", "error", "Unknown command received.");
- }
- emit_signal("log_updated", command, message);
- if (command_array.size() == 2 && command != "error") {
- int command_type = command_array[0];
- switch (command_type) {
- case LOBBY_REQUEST: {
- Ref response = command_array[1];
- if (response.is_valid()) {
- Ref result = Ref(memnew(LobbyResponse::LobbyResult));
- response->emit_signal("finished", result);
- }
- } break;
- case LOBBY_VIEW: {
- Dictionary lobby_dict = data_dict.get("lobby", Dictionary());
-
- // Iterate through peers and populate arrays
- TypedArray peers_info;
- _update_peers(data_dict, peers_info);
- sort_peers_by_id(peers_info);
- Ref lobby_info = Ref(memnew(LobbyInfo));
- lobby_info->set_dict(lobby_dict);
- // notify
- Ref response = command_array[1];
- if (response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_peers(peers_info);
- result->set_lobby(lobby_info);
- response->emit_signal("finished", result);
- }
- } break;
- }
- }
-}
diff --git a/modules/blazium_sdk/lobby/authoritative_lobby_client.h b/modules/blazium_sdk/lobby/authoritative_lobby_client.h
deleted file mode 100644
index 8806288c8a4d..000000000000
--- a/modules/blazium_sdk/lobby/authoritative_lobby_client.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/**************************************************************************/
-/* lobby_client.h */
-/**************************************************************************/
-/* This file is part of: */
-/* BLAZIUM ENGINE */
-/* https://blazium.app */
-/**************************************************************************/
-/* Copyright (c) 2024-present Blazium Engine contributors. */
-/* Copyright (c) 2024 Dragos Daian, Randolph William Aarseth II. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef AUTHORITATIVE_LOBBY_CLIENT_H
-#define AUTHORITATIVE_LOBBY_CLIENT_H
-
-#include "authoritative_lobby_response.h"
-#include "lobby_client.h"
-
-class AuthoritativeLobbyClient : public BlaziumClient {
- GDCLASS(AuthoritativeLobbyClient, BlaziumClient);
-
-protected:
- String server_url = "wss://authlobby.blazium.app/connect";
- String reconnection_token = "";
- String game_id = "";
- Dictionary peer_data = Dictionary();
- Ref lobby;
- Ref peer;
- TypedArray peers = TypedArray();
-
- Ref _socket;
- int _counter = 0;
- bool connected = false;
- Dictionary _commands;
-
- void _clear_lobby();
- void _receive_data(const Dictionary &p_data);
- void _send_data(const Dictionary &p_data);
- void _update_peers(Dictionary p_data_dict, TypedArray &peers);
- String _increment_counter();
-
- enum CommandType {
- LOBBY_REQUEST = 0,
- LOBBY_VIEW,
- LOBBY_LIST,
- LOBBY_CALL
- };
-
- void _notification(int p_notification);
- static void _bind_methods();
-
-public:
- void set_server_url(const String &p_server_url);
- String get_server_url();
- void set_reconnection_token(const String &p_reconnection_token);
- String get_reconnection_token();
- void set_game_id(const String &p_game_id);
- String get_game_id();
- bool is_host();
- bool get_connected();
- Dictionary get_peer_data();
- void set_lobby(const Ref &p_lobby);
- Ref get_lobby();
- void set_peer(const Ref &p_peer);
- Ref get_peer();
- TypedArray get_peers();
-
- bool connect_to_lobby();
- void disconnect_from_lobby();
- Ref create_lobby(const String &p_name, const Dictionary &p_tags, int p_max_players, const String &p_password);
- Ref join_lobby(const String &p_lobby_id, const String &p_password);
- Ref leave_lobby();
- Ref list_lobby(const Dictionary &p_tags, int p_start, int p_count);
- Ref kick_peer(const String &p_peer_id);
-
- Ref add_user_data(const Dictionary &p_user_data);
- Ref del_user_data(const TypedArray &p_keys);
-
- Ref set_lobby_tags(const Dictionary &p_tags);
- Ref del_lobby_tags(const TypedArray &p_keys);
-
- Ref lobby_chat(const String &chat_message);
- Ref lobby_ready(bool p_ready);
- Ref seal_lobby(bool seal);
- Ref lobby_call(const String &p_method, const Array &p_args);
-
- AuthoritativeLobbyClient();
- ~AuthoritativeLobbyClient();
-};
-
-#endif // AUTHORITATIVE_LOBBY_CLIENT_H
diff --git a/modules/blazium_sdk/lobby/authoritative_lobby_response.h b/modules/blazium_sdk/lobby/authoritative_lobby_response.h
deleted file mode 100644
index baa0b7818cd1..000000000000
--- a/modules/blazium_sdk/lobby/authoritative_lobby_response.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**************************************************************************/
-/* authoritative_lobby_response.h */
-/**************************************************************************/
-/* This file is part of: */
-/* BLAZIUM ENGINE */
-/* https://blazium.app */
-/**************************************************************************/
-/* Copyright (c) 2024-present Blazium Engine contributors. */
-/* Copyright (c) 2024 Dragos Daian, Randolph William Aarseth II. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef AUTHORITATIVE_LOBBY_RESPONSE_H
-#define AUTHORITATIVE_LOBBY_RESPONSE_H
-
-#include "core/object/ref_counted.h"
-#include "core/variant/typed_array.h"
-#include "lobby_info.h"
-#include "lobby_peer.h"
-
-class AuthoritativeLobbyResponse : public RefCounted {
- GDCLASS(AuthoritativeLobbyResponse, RefCounted);
-
-protected:
- static void _bind_methods() {
- ADD_SIGNAL(MethodInfo("finished", PropertyInfo(Variant::OBJECT, "result", PROPERTY_HINT_RESOURCE_TYPE, "AuthoritativeLobbyResult")));
- }
-
-public:
- class AuthoritativeLobbyResult : public RefCounted {
- GDCLASS(AuthoritativeLobbyResult, RefCounted);
- Variant result;
- String error;
-
- protected:
- static void _bind_methods() {
- ClassDB::bind_method(D_METHOD("has_error"), &AuthoritativeLobbyResult::has_error);
- ClassDB::bind_method(D_METHOD("get_error"), &AuthoritativeLobbyResult::get_error);
- ClassDB::bind_method(D_METHOD("get_result"), &AuthoritativeLobbyResult::get_result);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "error"), "", "get_error");
- }
-
- public:
- void set_error(String p_error) { this->error = p_error; }
- void set_result(Variant p_result) { this->result = p_result; }
-
- bool has_error() const { return !error.is_empty(); }
- String get_error() const { return error; }
- Variant get_result() const { return result; }
- };
-};
-
-#endif // AUTHORITATIVE_LOBBY_RESPONSE_H
diff --git a/modules/blazium_sdk/lobby/lobby_client.cpp b/modules/blazium_sdk/lobby/lobby_client.cpp
deleted file mode 100644
index e7e905640091..000000000000
--- a/modules/blazium_sdk/lobby/lobby_client.cpp
+++ /dev/null
@@ -1,963 +0,0 @@
-/**************************************************************************/
-/* lobby_client.cpp */
-/**************************************************************************/
-/* This file is part of: */
-/* BLAZIUM ENGINE */
-/* https://blazium.app */
-/**************************************************************************/
-/* Copyright (c) 2024-present Blazium Engine contributors. */
-/* Copyright (c) 2024 Dragos Daian, Randolph William Aarseth II. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#include "./lobby_client.h"
-#include "lobby_info.h"
-#include "scene/main/node.h"
-LobbyClient::LobbyClient() {
- lobby.instantiate();
- peer.instantiate();
- _socket = Ref(WebSocketPeer::create());
- set_process_internal(false);
-}
-
-LobbyClient::~LobbyClient() {
- _socket->close();
- set_process_internal(false);
-}
-
-void LobbyClient::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_server_url", "server_url"), &LobbyClient::set_server_url);
- ClassDB::bind_method(D_METHOD("get_server_url"), &LobbyClient::get_server_url);
- ClassDB::bind_method(D_METHOD("set_reconnection_token", "reconnection_token"), &LobbyClient::set_reconnection_token);
- ClassDB::bind_method(D_METHOD("get_reconnection_token"), &LobbyClient::get_reconnection_token);
- ClassDB::bind_method(D_METHOD("set_game_id", "game_id"), &LobbyClient::set_game_id);
- ClassDB::bind_method(D_METHOD("get_game_id"), &LobbyClient::get_game_id);
-
- ClassDB::bind_method(D_METHOD("is_host"), &LobbyClient::is_host);
- ClassDB::bind_method(D_METHOD("get_connected"), &LobbyClient::get_connected);
- ClassDB::bind_method(D_METHOD("get_lobby"), &LobbyClient::get_lobby);
- ClassDB::bind_method(D_METHOD("get_peer"), &LobbyClient::get_peer);
- ClassDB::bind_method(D_METHOD("get_peers"), &LobbyClient::get_peers);
- ClassDB::bind_method(D_METHOD("get_host_data"), &LobbyClient::get_host_data);
- ClassDB::bind_method(D_METHOD("get_peer_data"), &LobbyClient::get_peer_data);
-
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "server_url", PROPERTY_HINT_NONE, ""), "set_server_url", "get_server_url");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "reconnection_token", PROPERTY_HINT_NONE, ""), "set_reconnection_token", "get_reconnection_token");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "game_id", PROPERTY_HINT_NONE, ""), "set_game_id", "get_game_id");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "connected"), "", "get_connected");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "lobby", PROPERTY_HINT_RESOURCE_TYPE, "LobbyInfo"), "", "get_lobby");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), "", "get_peer");
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "peers", PROPERTY_HINT_ARRAY_TYPE, "LobbyPeer"), "", "get_peers");
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "host_data"), "", "get_host_data");
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "peer_data"), "", "get_peer_data");
- ADD_PROPERTY_DEFAULT("peers", TypedArray());
- ADD_PROPERTY_DEFAULT("peer", Ref());
- ADD_PROPERTY_DEFAULT("lobby", Ref());
- // Register methods
- ClassDB::bind_method(D_METHOD("connect_to_lobby"), &LobbyClient::connect_to_lobby);
- ClassDB::bind_method(D_METHOD("disconnect_from_lobby"), &LobbyClient::disconnect_from_lobby);
- ClassDB::bind_method(D_METHOD("create_lobby", "title", "tags", "max_players", "password"), &LobbyClient::create_lobby, DEFVAL(Dictionary()), DEFVAL(4), DEFVAL(""));
- ClassDB::bind_method(D_METHOD("join_lobby", "lobby_id", "password"), &LobbyClient::join_lobby, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("leave_lobby"), &LobbyClient::leave_lobby);
- ClassDB::bind_method(D_METHOD("list_lobbies", "tags", "start", "count"), &LobbyClient::list_lobby, DEFVAL(Dictionary()), DEFVAL(0), DEFVAL(10));
- ClassDB::bind_method(D_METHOD("kick_peer", "peer_id"), &LobbyClient::kick_peer);
- ClassDB::bind_method(D_METHOD("send_chat_message", "chat_message"), &LobbyClient::lobby_chat);
- ClassDB::bind_method(D_METHOD("set_lobby_ready", "ready"), &LobbyClient::lobby_ready);
- ClassDB::bind_method(D_METHOD("add_lobby_tags", "tags"), &LobbyClient::set_lobby_tags);
- ClassDB::bind_method(D_METHOD("del_lobby_tags", "keys"), &LobbyClient::del_lobby_tags);
- ClassDB::bind_method(D_METHOD("set_lobby_sealed", "seal"), &LobbyClient::seal_lobby);
- ClassDB::bind_method(D_METHOD("notify_lobby", "data"), &LobbyClient::lobby_notify);
- ClassDB::bind_method(D_METHOD("notify_peer", "data", "target_peer"), &LobbyClient::peer_notify);
-
- ClassDB::bind_method(D_METHOD("add_peer_user_data", "data"), &LobbyClient::add_user_data);
- ClassDB::bind_method(D_METHOD("del_peer_user_data", "keys"), &LobbyClient::del_user_data);
-
- ClassDB::bind_method(D_METHOD("add_lobby_data", "data", "is_private"), &LobbyClient::lobby_data, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("del_lobby_data", "keys", "is_private"), &LobbyClient::del_lobby_data, DEFVAL(false));
-
- ClassDB::bind_method(D_METHOD("add_peer_data", "data", "target_peer", "is_private"), &LobbyClient::set_peer_data, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("del_peer_data", "keys", "target_peer", "is_private"), &LobbyClient::del_peer_data, DEFVAL(false));
-
- ClassDB::bind_method(D_METHOD("add_peers_data", "data", "is_private"), &LobbyClient::set_peers_data, DEFVAL(false));
- ClassDB::bind_method(D_METHOD("del_peers_data", "keys", "is_private"), &LobbyClient::del_peers_data, DEFVAL(false));
-
- // Register signals
- ADD_SIGNAL(MethodInfo("connected_to_lobby", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::STRING, "reconnection_token")));
- ADD_SIGNAL(MethodInfo("disconnected_from_lobby", PropertyInfo(Variant::STRING, "reason")));
- ADD_SIGNAL(MethodInfo("received_peer_user_data", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::OBJECT, "data")));
- ADD_SIGNAL(MethodInfo("lobby_notified", PropertyInfo(Variant::OBJECT, "data"), PropertyInfo(Variant::OBJECT, "from_peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("received_peer_data", PropertyInfo(Variant::OBJECT, "data"), PropertyInfo(Variant::OBJECT, "to_peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::BOOL, "is_private")));
- ADD_SIGNAL(MethodInfo("received_lobby_data", PropertyInfo(Variant::OBJECT, "data"), PropertyInfo(Variant::BOOL, "is_private")));
- ADD_SIGNAL(MethodInfo("lobby_created", PropertyInfo(Variant::OBJECT, "lobby", PROPERTY_HINT_RESOURCE_TYPE, "LobbyInfo"), PropertyInfo(Variant::ARRAY, "peers", PROPERTY_HINT_ARRAY_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("lobby_joined", PropertyInfo(Variant::OBJECT, "lobby", PROPERTY_HINT_RESOURCE_TYPE, "LobbyInfo"), PropertyInfo(Variant::ARRAY, "peers", PROPERTY_HINT_ARRAY_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("lobby_left", PropertyInfo(Variant::BOOL, "kicked")));
- ADD_SIGNAL(MethodInfo("lobby_sealed", PropertyInfo(Variant::BOOL, "sealed")));
- ADD_SIGNAL(MethodInfo("lobby_tagged", PropertyInfo(Variant::DICTIONARY, "tags")));
- ADD_SIGNAL(MethodInfo("peer_joined", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("peer_reconnected", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("peer_left", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::BOOL, "kicked")));
- ADD_SIGNAL(MethodInfo("peer_disconnected", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer")));
- ADD_SIGNAL(MethodInfo("peer_messaged", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::STRING, "chat_message")));
- ADD_SIGNAL(MethodInfo("peer_ready", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"), PropertyInfo(Variant::BOOL, "is_ready")));
- ADD_SIGNAL(MethodInfo("log_updated", PropertyInfo(Variant::STRING, "command"), PropertyInfo(Variant::STRING, "logs")));
-}
-
-void LobbyClient::set_server_url(const String &p_server_url) { this->server_url = p_server_url; }
-String LobbyClient::get_server_url() { return server_url; }
-void LobbyClient::set_reconnection_token(const String &p_reconnection_token) { this->reconnection_token = p_reconnection_token; }
-String LobbyClient::get_reconnection_token() { return reconnection_token; }
-void LobbyClient::set_game_id(const String &p_game_id) { this->game_id = p_game_id; }
-String LobbyClient::get_game_id() { return game_id; }
-bool LobbyClient::is_host() { return lobby->get_host() == peer->get_id(); }
-bool LobbyClient::get_connected() { return connected; }
-Dictionary LobbyClient::get_host_data() { return host_data; }
-Dictionary LobbyClient::get_peer_data() { return peer_data; }
-void LobbyClient::set_lobby(const Ref &p_lobby) { this->lobby = p_lobby; }
-Ref LobbyClient::get_lobby() { return lobby; }
-void LobbyClient::set_peer(const Ref &p_peer) { this->peer = p_peer; }
-Ref LobbyClient::get_peer() { return peer; }
-TypedArray LobbyClient::get_peers() { return peers; }
-
-bool LobbyClient::connect_to_lobby() {
- if (connected) {
- return true;
- }
- String lobby_url = get_server_url();
- String url = lobby_url;
- PackedStringArray protocols;
- protocols.push_back("blazium");
- protocols.push_back(game_id);
- if (reconnection_token != "") {
- protocols.push_back(reconnection_token);
- }
- _socket->set_supported_protocols(protocols);
- Error err = _socket->connect_to_url(url);
- if (err != OK) {
- set_process_internal(false);
- emit_signal("log_updated", "error", "Unable to connect to lobby server at: " + url);
- connected = false;
- return false;
- }
- set_process_internal(true);
- emit_signal("log_updated", "connect_to_lobby", "Connecting to: " + url);
- return true;
-}
-
-void LobbyClient::disconnect_from_lobby() {
- if (connected) {
- _socket->close(1000, "Normal Closure");
- connected = false;
- host_data = Dictionary();
- peer_data = Dictionary();
- peer->set_data(Dictionary());
- peers.clear();
- lobby->set_dict(Dictionary());
- set_process_internal(false);
- emit_signal("disconnected_from_lobby", _socket->get_close_reason());
- emit_signal("log_updated", "disconnect_from_lobby", "Disconnected from: " + get_server_url());
- }
-}
-
-String LobbyClient::_increment_counter() {
- return String::num(_counter++);
-}
-
-Ref LobbyClient::create_lobby(const String &p_name, const Dictionary &p_tags, int p_max_players, const String &p_password) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "create_lobby";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["name"] = p_name;
- data_dict["max_players"] = p_max_players;
- data_dict["password"] = p_password;
- data_dict["tags"] = p_tags;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_VIEW);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::join_lobby(const String &p_lobby_id, const String &p_password) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "join_lobby";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["lobby_id"] = p_lobby_id;
- data_dict["password"] = p_password;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_VIEW);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::leave_lobby() {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "leave_lobby";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::list_lobby(const Dictionary &p_tags, int p_start, int p_count) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "list_lobby";
- Dictionary data_dict;
- data_dict["id"] = id;
- data_dict["start"] = p_start;
- data_dict["count"] = p_count;
- Dictionary filter_dict;
- data_dict["filter"] = filter_dict;
- if (p_tags.size() != 0) {
- filter_dict["tags"] = p_tags;
- }
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_LIST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::kick_peer(const String &p_peer_id) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "kick_peer";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["peer_id"] = p_peer_id;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::set_lobby_tags(const Dictionary &p_tags) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "lobby_tags";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["tags"] = p_tags;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::del_lobby_tags(const TypedArray &p_keys) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "lobby_tags";
- Dictionary data_dict;
- command["data"] = data_dict;
- Dictionary data_object_dict;
- // set null value
- for (int i = 0; i < p_keys.size(); i++) {
- data_object_dict[p_keys[i]] = Variant();
- }
- data_dict["tags"] = data_object_dict;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::lobby_chat(const String &p_chat_message) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "chat_lobby";
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["chat"] = p_chat_message;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::lobby_ready(bool p_ready) {
- String id = _increment_counter();
- Dictionary command;
- if (p_ready) {
- command["command"] = "lobby_ready";
- } else {
- command["command"] = "lobby_unready";
- }
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::seal_lobby(bool seal) {
- String id = _increment_counter();
- Dictionary command;
- if (seal) {
- command["command"] = "seal_lobby";
- } else {
- command["command"] = "unseal_lobby";
- }
- Dictionary data_dict;
- command["data"] = data_dict;
- data_dict["id"] = id;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::lobby_notify(const Variant &p_peer_data) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "lobby_notify";
- Dictionary data_dict;
- data_dict["peer_data"] = p_peer_data;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::peer_notify(const Variant &p_peer_data, const String &p_target_peer) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "notify_to";
- Dictionary data_dict;
- data_dict["peer_data"] = p_peer_data;
- data_dict["target_peer"] = p_target_peer;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::add_user_data(const Dictionary &p_user_data) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "user_data";
- Dictionary data_dict;
- data_dict["user_data"] = p_user_data;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::del_user_data(const TypedArray &p_keys) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "user_data";
- Dictionary data_dict;
- Dictionary data_object_dict;
- data_dict["user_data"] = data_object_dict;
- // set null value
- for (int i = 0; i < p_keys.size(); i++) {
- data_object_dict[p_keys[i]] = Variant();
- }
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::lobby_data(const Dictionary &p_lobby_data, bool p_is_private) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "lobby_data";
- Dictionary data_dict;
- data_dict["lobby_data"] = p_lobby_data;
- data_dict["is_private"] = p_is_private;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::del_lobby_data(const TypedArray &p_keys, bool p_is_private) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "lobby_data";
- Dictionary data_dict;
- Dictionary data_object_dict;
- data_dict["lobby_data"] = data_object_dict;
- // set null value
- for (int i = 0; i < p_keys.size(); i++) {
- data_object_dict[p_keys[i]] = Variant();
- }
- data_dict["is_private"] = p_is_private;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::set_peer_data(const Dictionary &p_peer_data, const String &p_target_peer, bool p_is_private) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "data_to";
- Dictionary data_dict;
- data_dict["peer_data"] = p_peer_data;
- data_dict["target_peer"] = p_target_peer;
- data_dict["is_private"] = p_is_private;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::del_peer_data(const TypedArray &p_keys, const String &p_target_peer, bool p_is_private) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "data_to";
- Dictionary data_dict;
- Dictionary data_object_dict;
- data_dict["peer_data"] = data_object_dict;
- // set null value
- for (int i = 0; i < p_keys.size(); i++) {
- data_object_dict[p_keys[i]] = Variant();
- }
- data_dict["target_peer"] = p_target_peer;
- data_dict["is_private"] = p_is_private;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::set_peers_data(const Dictionary &p_peer_data, bool p_is_private) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "data_to_all";
- Dictionary data_dict;
- data_dict["peer_data"] = p_peer_data;
- data_dict["is_private"] = p_is_private;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-Ref LobbyClient::del_peers_data(const TypedArray &p_keys, bool p_is_private) {
- String id = _increment_counter();
- Dictionary command;
- command["command"] = "data_to_all";
- Dictionary data_dict;
- Dictionary data_object_dict;
- data_dict["peer_data"] = data_object_dict;
- // set null value
- for (int i = 0; i < p_keys.size(); i++) {
- data_object_dict[p_keys[i]] = Variant();
- }
- data_dict["is_private"] = p_is_private;
- data_dict["id"] = id;
- command["data"] = data_dict;
- Array command_array;
- Ref response;
- response.instantiate();
- command_array.push_back(LOBBY_REQUEST);
- command_array.push_back(response);
- _commands[id] = command_array;
- _send_data(command);
- return response;
-}
-
-void LobbyClient::_notification(int p_what) {
- switch (p_what) {
- case NOTIFICATION_INTERNAL_PROCESS: {
- _socket->poll();
-
- WebSocketPeer::State state = _socket->get_ready_state();
- if (state == WebSocketPeer::STATE_OPEN) {
- if (!connected) {
- connected = true;
- emit_signal("log_updated", "connect_to_lobby", "Connected to: " + server_url);
- }
- while (_socket->get_available_packet_count() > 0) {
- Vector packet_buffer;
- Error err = _socket->get_packet_buffer(packet_buffer);
- if (err != OK) {
- emit_signal("log_updated", "error", "Unable to get packet.");
- return;
- }
- String packet_string = String::utf8((const char *)packet_buffer.ptr(), packet_buffer.size());
- _receive_data(JSON::parse_string(packet_string));
- }
- } else if (state == WebSocketPeer::STATE_CLOSED) {
- emit_signal("log_updated", "error", _socket->get_close_reason());
- emit_signal("disconnected_from_lobby", _socket->get_close_reason());
- set_process_internal(false);
- connected = false;
- }
- } break;
- }
-}
-
-void LobbyClient::_send_data(const Dictionary &p_data_dict) {
- if (_socket->get_ready_state() != WebSocketPeer::STATE_OPEN) {
- emit_signal("log_updated", "error", "Socket is not ready.");
- return;
- }
- Error err = _socket->send_text(JSON::stringify(p_data_dict));
- if (err != OK) {
- emit_signal("log_updated", "error", "No longer connected.");
- _socket->close(1000, "Disconnected");
- }
-}
-
-void LobbyClient::_update_peers(Dictionary p_data_dict, TypedArray &p_peers) {
- Array peers_array = p_data_dict.get("peers", Array());
- TypedArray peers_info;
- p_peers.clear();
- for (int i = 0; i < peers_array.size(); ++i) {
- Ref peer_info = Ref(memnew(LobbyPeer));
- Dictionary peer_dict = peers_array[i];
- peer_info->set_dict(peer_dict);
- if (peer_dict.has("private_data")) {
- peer_data = peer_dict.get("private_data", Dictionary());
- }
- p_peers.push_back(peer_info);
- }
-}
-
-// TODO optimize this
-void sort_peers_by_id(TypedArray &peers) {
- for (int i = 0; i < peers.size(); ++i) {
- for (int j = i + 1; j < peers.size(); ++j) {
- Ref peer_i = peers[i];
- Ref peer_j = peers[j];
- if (peer_i->get_id().casecmp_to(peer_j->get_id()) > 0) {
- Ref temp = peers[i];
- peers[i] = peers[j];
- peers[j] = temp;
- }
- }
- }
-}
-
-void LobbyClient::_clear_lobby() {
- lobby->set_dict(Dictionary());
- peers.clear();
- host_data = Dictionary();
- peer_data = Dictionary();
- peer->set_data(Dictionary());
- peer->set_ready(false);
-}
-
-void LobbyClient::_receive_data(const Dictionary &p_dict) {
- String command = p_dict.get("command", "error");
- String message = p_dict.get("message", "");
- Dictionary data_dict = p_dict.get("data", Dictionary());
- String message_id = data_dict.get("id", "");
- Array command_array = _commands.get(message_id, Array());
- _commands.erase(message_id);
- // update lobby and peers
- {
- TypedArray peers_info;
- if (data_dict.has("peers")) {
- // Iterate through peers and populate arrays
- _update_peers(data_dict, peers_info);
- sort_peers_by_id(peers_info);
- }
- if (data_dict.has("lobby")) {
- Dictionary lobby_dict = data_dict.get("lobby", Dictionary());
- Ref lobby_info = Ref(memnew(LobbyInfo));
- lobby_info->set_dict(lobby_dict);
- if (lobby_info->get_id() == lobby->get_id() || command == "lobby_created" || command == "joined_lobby") {
- // Update lobby info because we viewed our own lobby
- lobby->set_dict(lobby_info->get_dict());
- if (lobby_dict.has("private_data")) {
- host_data = lobby_dict.get("private_data", Dictionary());
- }
- peers = peers_info;
- }
- }
- }
- if (command == "peer_state") {
- Dictionary peer_dict = data_dict.get("peer", Dictionary());
- peer->set_dict(peer_dict);
- reconnection_token = peer_dict.get("reconnection_token", "");
- emit_signal("connected_to_lobby", peer, reconnection_token);
- } else if (command == "lobby_created") {
- emit_signal("lobby_created", lobby, peers);
- } else if (command == "joined_lobby") {
- emit_signal("lobby_joined", lobby, peers);
- } else if (command == "lobby_left") {
- _clear_lobby();
- emit_signal("lobby_left", false);
- } else if (command == "lobby_kicked") {
- _clear_lobby();
- emit_signal("lobby_left", true);
- } else if (command == "lobby_sealed") {
- Dictionary lobby_dict = data_dict.get("lobby", Dictionary());
- lobby->set_sealed(true);
- emit_signal("lobby_sealed", true);
- } else if (command == "lobby_unsealed") {
- lobby->set_sealed(false);
- emit_signal("lobby_sealed", false);
- } else if (command == "lobby_tags") {
- lobby->set_tags(data_dict.get("tags", Dictionary()));
- emit_signal("lobby_tagged", lobby->get_tags());
- } else if (command == "lobby_list") {
- Array arr = data_dict.get("lobbies", Array());
- TypedArray lobbies_input = arr;
- TypedArray lobbies_output;
- for (int i = 0; i < lobbies_input.size(); ++i) {
- Dictionary lobby_dict = lobbies_input[i];
- Ref lobby_info;
- lobby_info.instantiate();
- lobby_info->set_dict(lobby_dict);
-
- lobbies_output.push_back(lobby_info);
- }
- if (command_array.size() == 2) {
- Ref response = command_array[1];
- if (response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_lobbies(lobbies_output);
- response->emit_signal("finished", result);
- }
- }
- } else if (command == "peer_chat") {
- String peer_id = data_dict.get("from_peer", "");
- String chat_data = data_dict.get("chat_data", "");
- for (int i = 0; i < peers.size(); ++i) {
- Ref found_peer = peers[i];
- if (found_peer->get_id() == peer_id) {
- emit_signal("peer_messaged", found_peer, chat_data);
- break;
- }
- }
- } else if (command == "peer_user_data") {
- String peer_id = data_dict.get("peer_id", "");
- Dictionary peer_user_data = data_dict.get("user_data", "");
- if (peer->get_id() == peer_id) {
- peer->set_user_data(peer_user_data);
- // notify self
- emit_signal("received_peer_user_data", peer, peer_user_data);
- } else {
- // another peer got user data changed
- for (int i = 0; i < peers.size(); ++i) {
- Ref updated_peer = peers[i];
- if (updated_peer->get_id() == peer_id) {
- updated_peer->set_user_data(peer_user_data);
- emit_signal("received_peer_user_data", updated_peer, peer_user_data);
- break;
- }
- }
- }
- } else if (command == "peer_ready") {
- String peer_id = data_dict.get("peer_id", "");
- if (peer->get_id() == peer_id) {
- peer->set_ready(true);
- }
- for (int i = 0; i < peers.size(); ++i) {
- Ref updated_peer = peers[i];
- if (updated_peer->get_id() == String(peer_id)) {
- updated_peer->set_ready(true);
- emit_signal("peer_ready", updated_peer, true);
- break;
- }
- }
- } else if (command == "peer_unready") {
- String peer_id = data_dict.get("peer_id", "");
- if (peer->get_id() == peer_id) {
- peer->set_ready(false);
- }
- for (int i = 0; i < peers.size(); ++i) {
- Ref updated_peer = peers[i];
- if (updated_peer->get_id() == String(data_dict.get("peer_id", ""))) {
- updated_peer->set_ready(false);
- emit_signal("peer_ready", updated_peer, false);
- break;
- }
- }
- } else if (command == "peer_joined") {
- Ref joining_peer = Ref(memnew(LobbyPeer));
- Dictionary peer_dict = data_dict.get("peer", Dictionary());
- joining_peer->set_id(peer_dict.get("id", ""));
- joining_peer->set_user_data(peer_dict.get("user_data", ""));
- peers.append(joining_peer);
- sort_peers_by_id(peers);
- lobby->set_players(peers.size());
- emit_signal("peer_joined", joining_peer);
- } else if (command == "peer_reconnected") {
- for (int i = 0; i < peers.size(); ++i) {
- Ref updated_peer = peers[i];
- if (updated_peer->get_id() == String(data_dict.get("peer_id", ""))) {
- emit_signal("peer_reconnected", updated_peer);
- break;
- }
- }
- } else if (command == "peer_left") {
- for (int i = 0; i < peers.size(); ++i) {
- Ref leaving_peer = peers[i];
- if (leaving_peer->get_id() == String(data_dict.get("peer_id", ""))) {
- peers.remove_at(i);
- lobby->set_players(peers.size());
- emit_signal("peer_left", leaving_peer, data_dict.get("kicked", false));
- break;
- }
- }
- sort_peers_by_id(peers);
- } else if (command == "peer_disconnected") {
- for (int i = 0; i < peers.size(); ++i) {
- Ref leaving_peer = peers[i];
- if (leaving_peer->get_id() == String(data_dict.get("peer_id", ""))) {
- peers.remove_at(i);
- lobby->set_players(peers.size());
- emit_signal("peer_disconnected", leaving_peer);
- break;
- }
- }
- sort_peers_by_id(peers);
- } else if (command == "peer_notify") {
- String from_peer_id = data_dict.get("from_peer", "");
- for (int i = 0; i < peers.size(); ++i) {
- Ref from_peer = peers[i];
- if (from_peer->get_id() == from_peer_id) {
- emit_signal("lobby_notified", data_dict.get("peer_data", Variant()), from_peer);
- break;
- }
- }
- } else if (command == "lobby_data") {
- Dictionary lobby_data = data_dict.get("lobby_data", Dictionary());
- bool is_private = data_dict.get("is_private", false);
- if (is_private) {
- host_data = lobby_data;
- } else {
- lobby->set_data(lobby_data);
- }
- emit_signal("received_lobby_data", lobby_data, is_private);
- // nothing for now
- } else if (command == "data_to") {
- String target_peer_id = data_dict.get("target_peer", "");
- bool is_private = data_dict.get("is_private", false);
- Dictionary peer_data_variant = data_dict.get("peer_data", Dictionary());
- for (int i = 0; i < peers.size(); ++i) {
- Ref updated_peer = peers[i];
- if (updated_peer->get_id() == target_peer_id) {
- // got peer data, update it
- if (is_private && target_peer_id == peer->get_id()) {
- // private data, update self
- peer_data = peer_data_variant;
- } else {
- // public peer data
- updated_peer->set_data(peer_data_variant);
- }
- emit_signal("received_peer_data", peer_data_variant, updated_peer, is_private);
- break;
- }
- }
- } else if (command == "notified_to") {
- String from_peer_id = data_dict.get("from_peer", "");
- for (int i = 0; i < peers.size(); ++i) {
- Ref from_peer = peers[i];
- if (from_peer->get_id() == from_peer_id) {
- emit_signal("lobby_notified", data_dict.get("peer_data", Variant()), from_peer);
- break;
- }
- }
- } else if (command == "data_to_sent") {
- // nothing for now
- } else if (command == "lobby_notify_sent") {
- // nothing for now
- } else if (command == "notify_to_sent") {
- // nothing for now
- } else if (command == "error") {
- if (command_array.size() == 2) {
- int command_type = command_array[0];
- switch (command_type) {
- case LOBBY_REQUEST: {
- Ref lobby_response = command_array[1];
- if (lobby_response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_error(message);
- lobby_response->emit_signal("finished", result);
- }
- } break;
- case LOBBY_LIST: {
- Ref list_response = command_array[1];
- if (list_response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_error(message);
- list_response->emit_signal("finished", result);
- }
- } break;
- case LOBBY_VIEW: {
- Ref view_response = command_array[1];
- if (view_response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_error(message);
- view_response->emit_signal("finished", result);
- }
- } break;
- }
- }
- } else {
- emit_signal("log_updated", "error", "Unknown command received.");
- }
- emit_signal("log_updated", command, message);
- if (command_array.size() == 2 && command != "error") {
- int command_type = command_array[0];
- switch (command_type) {
- case LOBBY_REQUEST: {
- Ref response = command_array[1];
- if (response.is_valid()) {
- Ref result = Ref(memnew(LobbyResponse::LobbyResult));
- response->emit_signal("finished", result);
- }
- } break;
- case LOBBY_VIEW: {
- Dictionary lobby_dict = data_dict.get("lobby", Dictionary());
-
- // Iterate through peers and populate arrays
- TypedArray peers_info;
- _update_peers(data_dict, peers_info);
- sort_peers_by_id(peers_info);
- Ref lobby_info = Ref(memnew(LobbyInfo));
- lobby_info->set_dict(lobby_dict);
- // notify
- Ref response = command_array[1];
- if (response.is_valid()) {
- Ref result;
- result.instantiate();
- result->set_peers(peers_info);
- result->set_lobby(lobby_info);
- response->emit_signal("finished", result);
- }
- } break;
- }
- }
-}
diff --git a/modules/blazium_sdk/lobby/lobby_client.h b/modules/blazium_sdk/lobby/lobby_client.h
deleted file mode 100644
index 0296cb61292f..000000000000
--- a/modules/blazium_sdk/lobby/lobby_client.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/**************************************************************************/
-/* lobby_client.h */
-/**************************************************************************/
-/* This file is part of: */
-/* BLAZIUM ENGINE */
-/* https://blazium.app */
-/**************************************************************************/
-/* Copyright (c) 2024-present Blazium Engine contributors. */
-/* Copyright (c) 2024 Dragos Daian, Randolph William Aarseth II. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef LOBBY_CLIENT_H
-#define LOBBY_CLIENT_H
-
-#include "../blazium_client.h"
-#include "core/io/json.h"
-#include "lobby_info.h"
-#include "lobby_peer.h"
-#include "lobby_response.h"
-#include "modules/websocket/websocket_peer.h"
-
-void sort_peers_by_id(TypedArray &peers);
-
-class LobbyClient : public BlaziumClient {
- GDCLASS(LobbyClient, BlaziumClient);
-
-protected:
- String server_url = "wss://lobby.blazium.app/connect";
- String reconnection_token = "";
- String game_id = "";
- Dictionary host_data = Dictionary();
- Dictionary peer_data = Dictionary();
- Ref lobby;
- Ref peer;
- TypedArray peers = TypedArray();
-
- Ref _socket;
- int _counter = 0;
- bool connected = false;
- Dictionary _commands;
-
- void _clear_lobby();
- void _receive_data(const Dictionary &p_data);
- void _send_data(const Dictionary &p_data);
- void _update_peers(Dictionary p_data_dict, TypedArray &peers);
- String _increment_counter();
-
- enum CommandType {
- LOBBY_REQUEST = 0,
- LOBBY_VIEW,
- LOBBY_LIST,
- };
-
- void _notification(int p_notification);
- static void _bind_methods();
-
-public:
- void set_server_url(const String &p_server_url);
- String get_server_url();
- void set_reconnection_token(const String &p_reconnection_token);
- String get_reconnection_token();
- void set_game_id(const String &p_game_id);
- String get_game_id();
- bool is_host();
- bool get_connected();
- Dictionary get_host_data();
- Dictionary get_peer_data();
- void set_lobby(const Ref &p_lobby);
- Ref get_lobby();
- void set_peer(const Ref &p_peer);
- Ref get_peer();
- TypedArray get_peers();
-
- bool connect_to_lobby();
- void disconnect_from_lobby();
- Ref create_lobby(const String &p_name, const Dictionary &p_tags, int p_max_players, const String &p_password);
- Ref join_lobby(const String &p_lobby_id, const String &p_password);
- Ref leave_lobby();
- Ref list_lobby(const Dictionary &p_tags, int p_start, int p_count);
- Ref kick_peer(const String &p_peer_id);
- Ref set_lobby_tags(const Dictionary &p_tags);
- Ref del_lobby_tags(const TypedArray &p_keys);
- Ref lobby_chat(const String &chat_message);
- Ref lobby_ready(bool p_ready);
- Ref seal_lobby(bool seal);
- Ref lobby_notify(const Variant &p_peer_data);
- Ref peer_notify(const Variant &p_peer_data, const String &p_target_peer);
-
- Ref add_user_data(const Dictionary &p_user_data);
- Ref del_user_data(const TypedArray &p_keys);
-
- Ref lobby_data(const Dictionary &p_lobby_data, bool p_is_private);
- Ref del_lobby_data(const TypedArray &p_keys, bool p_is_private);
-
- Ref set_peer_data(const Dictionary &p_peer_data, const String &p_target_peer, bool p_is_private);
- Ref del_peer_data(const TypedArray &p_keys, const String &p_target_peer, bool p_is_private);
-
- Ref set_peers_data(const Dictionary &p_peer_data, bool p_is_private);
- Ref del_peers_data(const TypedArray &p_keys, bool p_is_private);
-
- LobbyClient();
- ~LobbyClient();
-};
-
-#endif // LOBBY_CLIENT_H
diff --git a/modules/blazium_sdk/lobby/lobby_info.cpp b/modules/blazium_sdk/lobby/lobby_info.cpp
deleted file mode 100644
index 297a37a8d5e4..000000000000
--- a/modules/blazium_sdk/lobby/lobby_info.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-#include "lobby_info.h"
-
-void LobbyInfo::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_host"), &LobbyInfo::get_host);
- ClassDB::bind_method(D_METHOD("get_max_players"), &LobbyInfo::get_max_players);
- ClassDB::bind_method(D_METHOD("is_sealed"), &LobbyInfo::is_sealed);
- ClassDB::bind_method(D_METHOD("is_password_protected"), &LobbyInfo::is_password_protected);
- ClassDB::bind_method(D_METHOD("get_id"), &LobbyInfo::get_id);
- ClassDB::bind_method(D_METHOD("get_lobby_name"), &LobbyInfo::get_lobby_name);
- ClassDB::bind_method(D_METHOD("get_players"), &LobbyInfo::get_players);
- ClassDB::bind_method(D_METHOD("get_tags"), &LobbyInfo::get_tags);
- ClassDB::bind_method(D_METHOD("get_data"), &LobbyInfo::get_data);
-
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "id"), "", "get_id");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "tags"), "", "get_tags");
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data"), "", "get_data");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "lobby_name"), "", "get_lobby_name");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "players"), "", "get_players");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "host"), "", "get_host");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "max_players"), "", "get_max_players");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sealed"), "", "is_sealed");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "password_protected"), "", "is_password_protected");
-}
-
-void LobbyInfo::set_id(const String &p_id) { id = p_id; }
-void LobbyInfo::set_lobby_name(const String &p_lobby_name) { lobby_name = p_lobby_name; }
-void LobbyInfo::set_host(const String &p_host) { host = p_host; }
-void LobbyInfo::set_max_players(int p_max_players) { max_players = p_max_players; }
-void LobbyInfo::set_players(int p_players) { players = p_players; }
-void LobbyInfo::set_sealed(bool p_sealed) { sealed = p_sealed; }
-void LobbyInfo::set_password_protected(bool p_password_protected) { password_protected = p_password_protected; }
-void LobbyInfo::set_tags(const Dictionary &p_tags) { tags = p_tags; }
-void LobbyInfo::set_data(const Dictionary &p_data) { data = p_data; }
-
-void LobbyInfo::set_dict(const Dictionary &p_dict) {
- set_host(p_dict.get("host", ""));
- set_max_players(p_dict.get("max_players", 0));
- set_sealed(p_dict.get("sealed", false));
- set_players(p_dict.get("players", 0));
- set_id(p_dict.get("id", ""));
- set_lobby_name(p_dict.get("name", ""));
- set_password_protected(p_dict.get("has_password", false));
- set_tags(p_dict.get("tags", Dictionary()));
- set_data(p_dict.get("public_data", Dictionary()));
-}
-Dictionary LobbyInfo::get_dict() const {
- Dictionary dict;
- dict["host"] = get_host();
- dict["max_players"] = get_max_players();
- dict["sealed"] = is_sealed();
- dict["players"] = get_players();
- dict["id"] = get_id();
- dict["name"] = get_lobby_name();
- dict["has_password"] = is_password_protected();
- dict["tags"] = get_tags();
- dict["public_data"] = get_data();
- return dict;
-}
-
-Dictionary LobbyInfo::get_data() const { return data; }
-Dictionary LobbyInfo::get_tags() const { return tags; }
-String LobbyInfo::get_id() const { return id; }
-String LobbyInfo::get_lobby_name() const { return lobby_name; }
-String LobbyInfo::get_host() const { return host; }
-int LobbyInfo::get_max_players() const { return max_players; }
-int LobbyInfo::get_players() const { return players; }
-bool LobbyInfo::is_sealed() const { return sealed; }
-bool LobbyInfo::is_password_protected() const { return password_protected; }
diff --git a/modules/blazium_sdk/lobby/lobby_info.h b/modules/blazium_sdk/lobby/lobby_info.h
deleted file mode 100644
index 37fea6919ed9..000000000000
--- a/modules/blazium_sdk/lobby/lobby_info.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/**************************************************************************/
-/* lobby_info.h */
-/**************************************************************************/
-/* This file is part of: */
-/* BLAZIUM ENGINE */
-/* https://blazium.app */
-/**************************************************************************/
-/* Copyright (c) 2024-present Blazium Engine contributors. */
-/* Copyright (c) 2024 Dragos Daian, Randolph William Aarseth II. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef LOBBY_INFO_H
-#define LOBBY_INFO_H
-
-#include "core/io/resource.h"
-
-class LobbyInfo : public Resource {
- GDCLASS(LobbyInfo, Resource);
- String id = "";
- String lobby_name = "";
- String host = "";
- Dictionary tags = Dictionary();
- Dictionary data = Dictionary();
- int max_players = 0;
- int players = 0;
- bool sealed = false;
- bool password_protected = false;
-
-protected:
- static void _bind_methods();
-
-public:
- void set_id(const String &p_id);
- void set_lobby_name(const String &p_lobby_name);
- void set_host(const String &p_host);
- void set_max_players(int p_max_players);
- void set_players(int p_players);
- void set_sealed(bool p_sealed);
- void set_password_protected(bool p_password_protected);
- void set_tags(const Dictionary &p_tags);
- void set_data(const Dictionary &p_data);
-
- void set_dict(const Dictionary &p_dict);
- Dictionary get_dict() const;
-
- Dictionary get_data() const;
- Dictionary get_tags() const;
- String get_id() const;
- String get_lobby_name() const;
- String get_host() const;
- int get_max_players() const;
- int get_players() const;
- bool is_sealed() const;
- bool is_password_protected() const;
-};
-
-#endif // LOBBY_INFO_H
diff --git a/modules/blazium_sdk/lobby/lobby_peer.cpp b/modules/blazium_sdk/lobby/lobby_peer.cpp
deleted file mode 100644
index cf51ec00ee62..000000000000
--- a/modules/blazium_sdk/lobby/lobby_peer.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "lobby_peer.h"
-
-void LobbyPeer::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_id"), &LobbyPeer::get_id);
- ClassDB::bind_method(D_METHOD("get_user_data"), &LobbyPeer::get_user_data);
- ClassDB::bind_method(D_METHOD("is_ready"), &LobbyPeer::is_ready);
- ClassDB::bind_method(D_METHOD("get_data"), &LobbyPeer::get_data);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "id"), "", "get_id");
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "user_data"), "", "get_user_data");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ready"), "", "is_ready");
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data"), "", "get_data");
-}
-
-void LobbyPeer::set_id(const String &p_id) { id = p_id; }
-void LobbyPeer::set_user_data(const Dictionary &p_user_data) { user_data = p_user_data; }
-void LobbyPeer::set_ready(bool p_ready) { ready = p_ready; }
-void LobbyPeer::set_data(const Dictionary &p_data) { data = p_data; }
-void LobbyPeer::set_dict(const Dictionary &p_dict) {
- set_id(p_dict.get("id", ""));
- set_user_data(p_dict.get("user_data", ""));
- set_ready(p_dict.get("ready", ""));
- set_data(p_dict.get("public_data", Dictionary()));
-}
-Dictionary LobbyPeer::get_dict() const {
- Dictionary dict;
- dict["id"] = get_id();
- dict["user_data"] = get_user_data();
- dict["ready"] = is_ready();
- dict["public_data"] = get_data();
- return dict;
-}
-
-Dictionary LobbyPeer::get_data() const { return data; }
-String LobbyPeer::get_id() const { return id; }
-Dictionary LobbyPeer::get_user_data() const { return user_data; }
-bool LobbyPeer::is_ready() const { return ready; }
diff --git a/modules/blazium_sdk/lobby/lobby_peer.h b/modules/blazium_sdk/lobby/lobby_peer.h
deleted file mode 100644
index e539383bf931..000000000000
--- a/modules/blazium_sdk/lobby/lobby_peer.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**************************************************************************/
-/* lobby_peer.h */
-/**************************************************************************/
-/* This file is part of: */
-/* BLAZIUM ENGINE */
-/* https://blazium.app */
-/**************************************************************************/
-/* Copyright (c) 2024-present Blazium Engine contributors. */
-/* Copyright (c) 2024 Dragos Daian, Randolph William Aarseth II. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef LOBBY_PEER_H
-#define LOBBY_PEER_H
-
-#include "core/io/resource.h"
-
-class LobbyPeer : public Resource {
- GDCLASS(LobbyPeer, Resource);
- String id = "";
- bool ready = false;
- Dictionary user_data = Dictionary();
- Dictionary data = Dictionary();
-
-protected:
- static void _bind_methods();
-
-public:
- void set_id(const String &p_id);
- void set_ready(bool p_ready);
- void set_data(const Dictionary &p_data);
- void set_dict(const Dictionary &p_dict);
- void set_user_data(const Dictionary &p_data);
-
- Dictionary get_dict() const;
- Dictionary get_data() const;
- String get_id() const;
- bool is_ready() const;
- Dictionary get_user_data() const;
-};
-
-#endif // LOBBY_PEER_H
diff --git a/modules/blazium_sdk/lobby/lobby_response.h b/modules/blazium_sdk/lobby/lobby_response.h
deleted file mode 100644
index 802250acd120..000000000000
--- a/modules/blazium_sdk/lobby/lobby_response.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/**************************************************************************/
-/* lobby_response.h */
-/**************************************************************************/
-/* This file is part of: */
-/* BLAZIUM ENGINE */
-/* https://blazium.app */
-/**************************************************************************/
-/* Copyright (c) 2024-present Blazium Engine contributors. */
-/* Copyright (c) 2024 Dragos Daian, Randolph William Aarseth II. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef LOBBY_RESPONSE_H
-#define LOBBY_RESPONSE_H
-
-#include "core/object/ref_counted.h"
-#include "core/variant/typed_array.h"
-#include "lobby_info.h"
-#include "lobby_peer.h"
-
-class LobbyResponse : public RefCounted {
- GDCLASS(LobbyResponse, RefCounted);
-
-protected:
- static void _bind_methods() {
- ADD_SIGNAL(MethodInfo("finished", PropertyInfo(Variant::OBJECT, "result", PROPERTY_HINT_RESOURCE_TYPE, "LobbyResult")));
- }
-
-public:
- class LobbyResult : public RefCounted {
- GDCLASS(LobbyResult, RefCounted);
-
- String error = "";
-
- protected:
- static void _bind_methods() {
- ClassDB::bind_method(D_METHOD("has_error"), &LobbyResult::has_error);
- ClassDB::bind_method(D_METHOD("get_error"), &LobbyResult::get_error);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "error"), "", "get_error");
- }
-
- public:
- void set_error(String p_error) { this->error = p_error; }
-
- bool has_error() const { return !error.is_empty(); }
- String get_error() const { return error; }
- };
-};
-
-class ListLobbyResponse : public RefCounted {
- GDCLASS(ListLobbyResponse, RefCounted);
-
-protected:
- static void _bind_methods() {
- ADD_SIGNAL(MethodInfo("finished", PropertyInfo(Variant::OBJECT, "result", PROPERTY_HINT_RESOURCE_TYPE, "ListLobbyResult")));
- }
-
-public:
- class ListLobbyResult : public RefCounted {
- GDCLASS(ListLobbyResult, RefCounted);
-
- String error = "";
- TypedArray lobbies = TypedArray();
-
- protected:
- static void _bind_methods() {
- ClassDB::bind_method(D_METHOD("has_error"), &ListLobbyResult::has_error);
- ClassDB::bind_method(D_METHOD("get_error"), &ListLobbyResult::get_error);
- 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");
- }
-
- public:
- void set_error(const String &p_error) { this->error = p_error; }
- void set_lobbies(const TypedArray &p_lobbies) { this->lobbies = p_lobbies; }
-
- bool has_error() const { return !error.is_empty(); }
- String get_error() const { return error; }
- TypedArray get_lobbies() const { return lobbies; }
- };
-};
-
-class ViewLobbyResponse : public RefCounted {
- GDCLASS(ViewLobbyResponse, RefCounted);
-
-protected:
- static void _bind_methods() {
- ADD_SIGNAL(MethodInfo("finished", PropertyInfo(Variant::OBJECT, "result", PROPERTY_HINT_RESOURCE_TYPE, "ViewLobbyResult")));
- }
-
-public:
- class ViewLobbyResult : public RefCounted {
- GDCLASS(ViewLobbyResult, RefCounted);
- String error = "";
- TypedArray peers_info = TypedArray();
- Ref lobby_info;
-
- protected:
- static void _bind_methods() {
- ClassDB::bind_method(D_METHOD("has_error"), &ViewLobbyResult::has_error);
- ClassDB::bind_method(D_METHOD("get_error"), &ViewLobbyResult::get_error);
- ClassDB::bind_method(D_METHOD("get_peers"), &ViewLobbyResult::get_peers);
- 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(PropertyInfo(Variant::STRING, "error"), "", "get_error");
- ADD_PROPERTY_DEFAULT("lobby", Ref());
- }
-
- public:
- void set_error(const String &p_error) { this->error = p_error; }
- void set_peers(const TypedArray &p_peers) { this->peers_info = p_peers; }
- void set_lobby(const Ref &p_lobby_info) { this->lobby_info = p_lobby_info; }
-
- bool has_error() const { return !error.is_empty(); }
- String get_error() const { return error; }
- TypedArray get_peers() const { return peers_info; }
- Ref get_lobby() const { return lobby_info; }
- ViewLobbyResult() {
- lobby_info.instantiate();
- }
- ~ViewLobbyResult() {
- }
- };
-};
-
-#endif // LOBBY_RESPONSE_H
diff --git a/modules/blazium_sdk/login/login_client.cpp b/modules/blazium_sdk/login/login_client.cpp
deleted file mode 100644
index 90be58557ebe..000000000000
--- a/modules/blazium_sdk/login/login_client.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "login_client.h"
-
-void LoginClient::_bind_methods() {
- ClassDB::bind_method(D_METHOD("request_login_info", "login_type"), &LoginClient::request_login_info);
- ClassDB::bind_method(D_METHOD("set_server_url", "server_url"), &LoginClient::set_server_url);
- ClassDB::bind_method(D_METHOD("get_server_url"), &LoginClient::get_server_url);
- ClassDB::bind_method(D_METHOD("set_game_id", "game_id"), &LoginClient::set_game_id);
- ClassDB::bind_method(D_METHOD("get_game_id"), &LoginClient::get_game_id);
- ClassDB::bind_method(D_METHOD("get_connected"), &LoginClient::get_connected);
-
- ClassDB::bind_method(D_METHOD("connect_to_server"), &LoginClient::connect_to_server);
- ClassDB::bind_method(D_METHOD("disconnect_from_server"), &LoginClient::disconnect_from_server);
-
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "server_url", PROPERTY_HINT_NONE, ""), "set_server_url", "get_server_url");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "game_id", PROPERTY_HINT_NONE, ""), "set_game_id", "get_game_id");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "connected"), "", "get_connected");
-
- ADD_SIGNAL(MethodInfo("log_updated", PropertyInfo(Variant::STRING, "command"), PropertyInfo(Variant::STRING, "logs")));
- ADD_SIGNAL(MethodInfo("disconnected_from_server", PropertyInfo(Variant::STRING, "reason")));
- ADD_SIGNAL(MethodInfo("connected_to_server"));
- ADD_SIGNAL(MethodInfo("received_jwt", PropertyInfo(Variant::STRING, "jwt"), PropertyInfo(Variant::STRING, "type")));
-}
-
-bool LoginClient::connect_to_server() {
- if (connected) {
- return true;
- }
- String lobby_url = get_server_url();
- String url = lobby_url;
- PackedStringArray protocols;
- protocols.push_back("blazium");
- protocols.push_back(game_id);
- _socket->set_supported_protocols(protocols);
- Error err = _socket->connect_to_url(url);
- if (err != OK) {
- set_process_internal(false);
- emit_signal("log_updated", "error", "Unable to connect to lobby server at: " + url);
- connected = false;
- return false;
- }
- set_process_internal(true);
- emit_signal("log_updated", "connect_to_lobby", "Connecting to: " + url);
- return true;
-}
-
-void LoginClient::disconnect_from_server() {
- if (connected) {
- _socket->close(1000, "Normal Closure");
- connected = false;
- set_process_internal(false);
- emit_signal("disconnected_from_server", _socket->get_close_reason());
- emit_signal("log_updated", "disconnected_from_server", "Disconnected from: " + get_server_url());
- }
-}
diff --git a/modules/blazium_sdk/login/login_client.h b/modules/blazium_sdk/login/login_client.h
deleted file mode 100644
index 918d75cfc2d6..000000000000
--- a/modules/blazium_sdk/login/login_client.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/**************************************************************************/
-/* login_client.h */
-/**************************************************************************/
-/* This file is part of: */
-/* BLAZIUM ENGINE */
-/* https://blazium.app */
-/**************************************************************************/
-/* Copyright (c) 2024-present Blazium Engine contributors. */
-/* Copyright (c) 2024 Dragos Daian, Randolph William Aarseth II. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/**************************************************************************/
-
-#ifndef LOGIN_CLIENT_H
-#define LOGIN_CLIENT_H
-
-#include "../blazium_client.h"
-#include "core/io/json.h"
-#include "modules/websocket/websocket_peer.h"
-
-class LoginClient : public BlaziumClient {
- GDCLASS(LoginClient, BlaziumClient);
-
-protected:
- String server_url = "wss://login.blazium.app/connect";
- String game_id = "";
- bool connected = false;
-
-public:
- class LoginResponse : public RefCounted {
- GDCLASS(LoginResponse, RefCounted);
-
- protected:
- static void _bind_methods() {
- ADD_SIGNAL(MethodInfo("finished", PropertyInfo(Variant::OBJECT, "result", PROPERTY_HINT_RESOURCE_TYPE, "LoginResult")));
- }
-
- public:
- class LoginResult : public RefCounted {
- GDCLASS(LoginResult, RefCounted);
-
- String error = "";
- String login_url = "";
- String login_type = "";
-
- protected:
- static void _bind_methods() {
- ClassDB::bind_method(D_METHOD("get_login_url"), &LoginResult::get_login_url);
- ClassDB::bind_method(D_METHOD("get_login_type"), &LoginResult::get_login_type);
- ClassDB::bind_method(D_METHOD("has_error"), &LoginResult::has_error);
- ClassDB::bind_method(D_METHOD("get_error"), &LoginResult::get_error);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "error"), "", "get_error");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "login_url"), "", "get_login_url");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "login_type"), "", "get_login_type");
- }
-
- public:
- void set_login_type(String p_type) { this->login_type = p_type; }
- void set_login_url(String p_url) { this->login_url = p_url; }
- void set_error(String p_error) { this->error = p_error; }
-
- bool has_error() const { return !error.is_empty(); }
- String get_error() const { return error; }
- String get_login_url() const { return login_url; }
- String get_login_type() const { return login_type; }
- };
- };
-
-protected:
- Ref _socket;
- Ref login_response;
-
- void _receive_data(const Dictionary &p_data) {
- String action = p_data.get("action", "");
- if (action == "login_url") {
- String url = p_data.get("url", "");
- String type = p_data.get("type", "");
- Ref