From a29a013b68ea1a6bea5079ee4564be5128ff8876 Mon Sep 17 00:00:00 2001 From: Dragos Daian Date: Fri, 20 Dec 2024 14:19:57 +0100 Subject: [PATCH] add peer user data --- .../doc_classes/AuthoritativeLobbyClient.xml | 40 +++++---- .../blazium_sdk/doc_classes/LobbyClient.xml | 40 +++++---- modules/blazium_sdk/doc_classes/LobbyInfo.xml | 3 - modules/blazium_sdk/doc_classes/LobbyPeer.xml | 6 +- .../lobby/authoritative_lobby_client.cpp | 82 +++++++++++------- .../lobby/authoritative_lobby_client.h | 6 +- modules/blazium_sdk/lobby/lobby_client.cpp | 83 ++++++++++++------- modules/blazium_sdk/lobby/lobby_client.h | 4 +- modules/blazium_sdk/lobby/lobby_info.cpp | 6 -- modules/blazium_sdk/lobby/lobby_info.h | 3 - modules/blazium_sdk/lobby/lobby_peer.cpp | 12 +-- modules/blazium_sdk/lobby/lobby_peer.h | 6 +- 12 files changed, 173 insertions(+), 118 deletions(-) diff --git a/modules/blazium_sdk/doc_classes/AuthoritativeLobbyClient.xml b/modules/blazium_sdk/doc_classes/AuthoritativeLobbyClient.xml index bdcd95833c4d..d877624babcd 100644 --- a/modules/blazium_sdk/doc_classes/AuthoritativeLobbyClient.xml +++ b/modules/blazium_sdk/doc_classes/AuthoritativeLobbyClient.xml @@ -34,6 +34,15 @@ 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]. + + @@ -63,6 +72,15 @@ 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]. + + @@ -148,15 +166,6 @@ Generates [signal lobby_sealed]. - - - - - Set your peer name. - Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished. - Generates [signal peer_named] signal if you are in lobby. - - @@ -269,12 +278,6 @@ Signal generated after a peer sends a chat message. - - - - Signal generated after a peer names himself. - - @@ -302,5 +305,12 @@ 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/LobbyClient.xml b/modules/blazium_sdk/doc_classes/LobbyClient.xml index 284805b6480b..9a86a7749585 100644 --- a/modules/blazium_sdk/doc_classes/LobbyClient.xml +++ b/modules/blazium_sdk/doc_classes/LobbyClient.xml @@ -52,6 +52,15 @@ 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]. + + @@ -112,6 +121,15 @@ 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]. + + @@ -218,15 +236,6 @@ Generates [signal lobby_sealed]. - - - - - Set your peer name. - Returns a [LobbyResponse] object that has a [signal LobbyResponse.finished] signal that is emitted when finished. - Generates [signal peer_named] signal if you are in lobby. - - @@ -343,12 +352,6 @@ Signal generated after a peer sends a chat message. - - - - Signal generated after a peer names himself. - - @@ -377,5 +380,12 @@ 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 index ed10adffe20b..5d2310a8952c 100644 --- a/modules/blazium_sdk/doc_classes/LobbyInfo.xml +++ b/modules/blazium_sdk/doc_classes/LobbyInfo.xml @@ -15,9 +15,6 @@ The host id of the lobby. - - The name of the host of the lobby. - The id of the lobby. diff --git a/modules/blazium_sdk/doc_classes/LobbyPeer.xml b/modules/blazium_sdk/doc_classes/LobbyPeer.xml index 812b6dc573cc..cb4a491f5c82 100644 --- a/modules/blazium_sdk/doc_classes/LobbyPeer.xml +++ b/modules/blazium_sdk/doc_classes/LobbyPeer.xml @@ -15,11 +15,11 @@ Identifier of the peer. - - Name of the peer. - Whether the peer is ready. + + Public user data of the peer. + diff --git a/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp b/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp index 59ce1486a55e..9544185fb117 100644 --- a/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp +++ b/modules/blazium_sdk/lobby/authoritative_lobby_client.cpp @@ -73,7 +73,6 @@ void AuthoritativeLobbyClient::_bind_methods() { // 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("set_peer_name", "peer_name"), &AuthoritativeLobbyClient::set_peer_name); 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); @@ -85,11 +84,13 @@ void AuthoritativeLobbyClient::_bind_methods() { 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("peer_named", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"))); + 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"))); @@ -283,6 +284,47 @@ Ref AuthoritativeLobbyClient::kick_peer(const String &p_peer_id) 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; @@ -363,24 +405,6 @@ Ref AuthoritativeLobbyClient::lobby_ready(bool p_ready) { return response; } -Ref AuthoritativeLobbyClient::set_peer_name(const String &p_peer_name) { - String id = _increment_counter(); - Dictionary command; - command["command"] = "set_name"; - Dictionary data_dict; - data_dict["name"] = p_peer_name; - 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::seal_lobby(bool seal) { String id = _increment_counter(); Dictionary command; @@ -550,24 +574,20 @@ void AuthoritativeLobbyClient::_receive_data(const Dictionary &p_dict) { break; } } - } else if (command == "peer_name") { + } else if (command == "peer_user_data") { String peer_id = data_dict.get("peer_id", ""); - String peer_name = data_dict.get("name", ""); + Dictionary peer_user_data = data_dict.get("user_data", ""); if (peer->get_id() == peer_id) { - peer->set_peer_name(peer_name); + peer->set_user_data(peer_user_data); // notify self - emit_signal("peer_named", peer); + 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_peer_name(peer_name); - // if the named peer is the host, update the host name - if (updated_peer->get_id() == lobby->get_host()) { - lobby->set_host_name(peer_name); - } - emit_signal("peer_named", updated_peer); + updated_peer->set_user_data(peer_user_data); + emit_signal("received_peer_user_data", updated_peer, peer_user_data); break; } } @@ -602,7 +622,7 @@ void AuthoritativeLobbyClient::_receive_data(const Dictionary &p_dict) { 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_peer_name(peer_dict.get("name", "")); + joining_peer->set_user_data(peer_dict.get("user_data", "")); peers.append(joining_peer); sort_peers_by_id(peers); lobby->set_players(peers.size()); diff --git a/modules/blazium_sdk/lobby/authoritative_lobby_client.h b/modules/blazium_sdk/lobby/authoritative_lobby_client.h index 4c1add803ded..8806288c8a4d 100644 --- a/modules/blazium_sdk/lobby/authoritative_lobby_client.h +++ b/modules/blazium_sdk/lobby/authoritative_lobby_client.h @@ -90,11 +90,15 @@ class AuthoritativeLobbyClient : public BlaziumClient { 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 set_peer_name(const String &p_peer_name); Ref seal_lobby(bool seal); Ref lobby_call(const String &p_method, const Array &p_args); diff --git a/modules/blazium_sdk/lobby/lobby_client.cpp b/modules/blazium_sdk/lobby/lobby_client.cpp index a7d3bd479ef4..e7e905640091 100644 --- a/modules/blazium_sdk/lobby/lobby_client.cpp +++ b/modules/blazium_sdk/lobby/lobby_client.cpp @@ -74,7 +74,6 @@ void LobbyClient::_bind_methods() { // 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("set_peer_name", "peer_name"), &LobbyClient::set_peer_name); 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); @@ -88,6 +87,9 @@ void LobbyClient::_bind_methods() { 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)); @@ -100,7 +102,7 @@ void LobbyClient::_bind_methods() { // 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("peer_named", PropertyInfo(Variant::OBJECT, "peer", PROPERTY_HINT_RESOURCE_TYPE, "LobbyPeer"))); + 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"))); @@ -357,14 +359,17 @@ Ref LobbyClient::lobby_ready(bool p_ready) { return response; } -Ref LobbyClient::set_peer_name(const String &p_peer_name) { +Ref LobbyClient::seal_lobby(bool seal) { String id = _increment_counter(); Dictionary command; - command["command"] = "set_name"; + if (seal) { + command["command"] = "seal_lobby"; + } else { + command["command"] = "unseal_lobby"; + } Dictionary data_dict; - data_dict["name"] = p_peer_name; - data_dict["id"] = id; command["data"] = data_dict; + data_dict["id"] = id; Array command_array; Ref response; response.instantiate(); @@ -375,17 +380,14 @@ Ref LobbyClient::set_peer_name(const String &p_peer_name) { return response; } -Ref LobbyClient::seal_lobby(bool seal) { +Ref LobbyClient::lobby_notify(const Variant &p_peer_data) { String id = _increment_counter(); Dictionary command; - if (seal) { - command["command"] = "seal_lobby"; - } else { - command["command"] = "unseal_lobby"; - } + command["command"] = "lobby_notify"; Dictionary data_dict; - command["data"] = data_dict; + data_dict["peer_data"] = p_peer_data; data_dict["id"] = id; + command["data"] = data_dict; Array command_array; Ref response; response.instantiate(); @@ -396,12 +398,13 @@ Ref LobbyClient::seal_lobby(bool seal) { return response; } -Ref LobbyClient::lobby_notify(const Variant &p_peer_data) { +Ref LobbyClient::peer_notify(const Variant &p_peer_data, const String &p_target_peer) { String id = _increment_counter(); Dictionary command; - command["command"] = "lobby_notify"; + 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; @@ -414,13 +417,35 @@ Ref LobbyClient::lobby_notify(const Variant &p_peer_data) { return response; } -Ref LobbyClient::peer_notify(const Variant &p_peer_data, const String &p_target_peer) { +Ref LobbyClient::add_user_data(const Dictionary &p_user_data) { String id = _increment_counter(); Dictionary command; - command["command"] = "notify_to"; + command["command"] = "user_data"; Dictionary data_dict; - data_dict["peer_data"] = p_peer_data; - data_dict["target_peer"] = p_target_peer; + 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; @@ -731,24 +756,20 @@ void LobbyClient::_receive_data(const Dictionary &p_dict) { break; } } - } else if (command == "peer_name") { + } else if (command == "peer_user_data") { String peer_id = data_dict.get("peer_id", ""); - String peer_name = data_dict.get("name", ""); + Dictionary peer_user_data = data_dict.get("user_data", ""); if (peer->get_id() == peer_id) { - peer->set_peer_name(peer_name); + peer->set_user_data(peer_user_data); // notify self - emit_signal("peer_named", peer); + emit_signal("received_peer_user_data", peer, peer_user_data); } else { - // another peer got named + // 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_peer_name(peer_name); - // if the named peer is the host, update the host name - if (updated_peer->get_id() == lobby->get_host()) { - lobby->set_host_name(peer_name); - } - emit_signal("peer_named", updated_peer); + updated_peer->set_user_data(peer_user_data); + emit_signal("received_peer_user_data", updated_peer, peer_user_data); break; } } @@ -783,7 +804,7 @@ void LobbyClient::_receive_data(const Dictionary &p_dict) { 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_peer_name(peer_dict.get("name", "")); + joining_peer->set_user_data(peer_dict.get("user_data", "")); peers.append(joining_peer); sort_peers_by_id(peers); lobby->set_players(peers.size()); diff --git a/modules/blazium_sdk/lobby/lobby_client.h b/modules/blazium_sdk/lobby/lobby_client.h index 20b04750ccd2..0296cb61292f 100644 --- a/modules/blazium_sdk/lobby/lobby_client.h +++ b/modules/blazium_sdk/lobby/lobby_client.h @@ -101,11 +101,13 @@ class LobbyClient : public BlaziumClient { Ref del_lobby_tags(const TypedArray &p_keys); Ref lobby_chat(const String &chat_message); Ref lobby_ready(bool p_ready); - Ref set_peer_name(const String &p_peer_name); 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); diff --git a/modules/blazium_sdk/lobby/lobby_info.cpp b/modules/blazium_sdk/lobby/lobby_info.cpp index fe33ad2ad745..297a37a8d5e4 100644 --- a/modules/blazium_sdk/lobby/lobby_info.cpp +++ b/modules/blazium_sdk/lobby/lobby_info.cpp @@ -7,7 +7,6 @@ void LobbyInfo::_bind_methods() { 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_host_name"), &LobbyInfo::get_host_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); @@ -16,7 +15,6 @@ void LobbyInfo::_bind_methods() { 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::STRING, "host_name"), "", "get_host_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"); @@ -27,7 +25,6 @@ void LobbyInfo::_bind_methods() { 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_host_name(const String &p_host_name) { host_name = p_host_name; } 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; } @@ -42,7 +39,6 @@ void LobbyInfo::set_dict(const Dictionary &p_dict) { set_players(p_dict.get("players", 0)); set_id(p_dict.get("id", "")); set_lobby_name(p_dict.get("name", "")); - set_host_name(p_dict.get("host_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())); @@ -55,7 +51,6 @@ Dictionary LobbyInfo::get_dict() const { dict["players"] = get_players(); dict["id"] = get_id(); dict["name"] = get_lobby_name(); - dict["host_name"] = get_host_name(); dict["has_password"] = is_password_protected(); dict["tags"] = get_tags(); dict["public_data"] = get_data(); @@ -67,7 +62,6 @@ 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; } -String LobbyInfo::get_host_name() const { return host_name; } int LobbyInfo::get_max_players() const { return max_players; } int LobbyInfo::get_players() const { return players; } bool LobbyInfo::is_sealed() const { return sealed; } diff --git a/modules/blazium_sdk/lobby/lobby_info.h b/modules/blazium_sdk/lobby/lobby_info.h index 6fb1a7b381e6..37fea6919ed9 100644 --- a/modules/blazium_sdk/lobby/lobby_info.h +++ b/modules/blazium_sdk/lobby/lobby_info.h @@ -38,7 +38,6 @@ class LobbyInfo : public Resource { String id = ""; String lobby_name = ""; String host = ""; - String host_name = ""; Dictionary tags = Dictionary(); Dictionary data = Dictionary(); int max_players = 0; @@ -53,7 +52,6 @@ class LobbyInfo : public Resource { 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_host_name(const String &p_host_name); void set_max_players(int p_max_players); void set_players(int p_players); void set_sealed(bool p_sealed); @@ -69,7 +67,6 @@ class LobbyInfo : public Resource { String get_id() const; String get_lobby_name() const; String get_host() const; - String get_host_name() const; int get_max_players() const; int get_players() const; bool is_sealed() const; diff --git a/modules/blazium_sdk/lobby/lobby_peer.cpp b/modules/blazium_sdk/lobby/lobby_peer.cpp index 25436b44cfc3..cf51ec00ee62 100644 --- a/modules/blazium_sdk/lobby/lobby_peer.cpp +++ b/modules/blazium_sdk/lobby/lobby_peer.cpp @@ -2,29 +2,29 @@ void LobbyPeer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_id"), &LobbyPeer::get_id); - ClassDB::bind_method(D_METHOD("get_peer_name"), &LobbyPeer::get_peer_name); + 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::STRING, "peer_name"), "", "get_peer_name"); + 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_peer_name(const String &p_peer_name) { peer_name = p_peer_name; } +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_peer_name(p_dict.get("name", "")); + 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["name"] = get_peer_name(); + dict["user_data"] = get_user_data(); dict["ready"] = is_ready(); dict["public_data"] = get_data(); return dict; @@ -32,5 +32,5 @@ Dictionary LobbyPeer::get_dict() const { Dictionary LobbyPeer::get_data() const { return data; } String LobbyPeer::get_id() const { return id; } -String LobbyPeer::get_peer_name() const { return peer_name; } +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 index eee10c92ec8a..e539383bf931 100644 --- a/modules/blazium_sdk/lobby/lobby_peer.h +++ b/modules/blazium_sdk/lobby/lobby_peer.h @@ -36,8 +36,8 @@ class LobbyPeer : public Resource { GDCLASS(LobbyPeer, Resource); String id = ""; - String peer_name = ""; bool ready = false; + Dictionary user_data = Dictionary(); Dictionary data = Dictionary(); protected: @@ -45,16 +45,16 @@ class LobbyPeer : public Resource { public: void set_id(const String &p_id); - void set_peer_name(const String &p_name); 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; - String get_peer_name() const; bool is_ready() const; + Dictionary get_user_data() const; }; #endif // LOBBY_PEER_H