Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
Ughuuu committed Dec 12, 2024
1 parent b3f55ce commit a0e8680
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
36 changes: 33 additions & 3 deletions modules/blazium_sdk/lobby/lobby_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,18 @@ void LobbyClient::_bind_methods() {
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("set_lobby_data", "data", "is_private"), &LobbyClient::lobby_data, DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_peer_data", "data", "target_peer", "is_private"), &LobbyClient::set_peer_data);
ClassDB::bind_method(D_METHOD("set_peers_data", "data", "is_private"), &LobbyClient::set_peers_data);
ClassDB::bind_method(D_METHOD("del_lobby_data", "key", "is_private"), &LobbyClient::del_lobby_data, DEFVAL(false));
ClassDB::bind_method(D_METHOD("clear_lobby_data", "is_private"), &LobbyClient::clear_lobby_data, DEFVAL(false));

ClassDB::bind_method(D_METHOD("set_peer_data", "data", "target_peer", "is_private"), &LobbyClient::set_peer_data, DEFVAL(false));
ClassDB::bind_method(D_METHOD("del_peer_data", "key", "target_peer", "is_private"), &LobbyClient::del_peer_data, DEFVAL(false));
ClassDB::bind_method(D_METHOD("clear_peer_data", "target_peer", "is_private"), &LobbyClient::clear_peer_data, DEFVAL(false));

ClassDB::bind_method(D_METHOD("set_peers_data", "data", "is_private"), &LobbyClient::set_peers_data, DEFVAL(false));
ClassDB::bind_method(D_METHOD("del_peers_data", "key", "is_private"), &LobbyClient::del_peers_data, DEFVAL(false));
ClassDB::bind_method(D_METHOD("clear_peers_data", "is_private"), &LobbyClient::clear_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")));
Expand Down Expand Up @@ -413,6 +422,27 @@ Ref<LobbyClient::LobbyResponse> LobbyClient::peer_notify(const Variant &p_peer_d
return response;
}

Ref<LobbyClient::LobbyResponse> LobbyClient::lobby_data_key_value(const String &p_key, const Variant &p_value, bool p_is_private) {
String id = _increment_counter();
Dictionary command;
command["command"] = "lobby_data";
Dictionary data_dict;
Dictionary key_value_dict;
key_value_dict[p_key] = p_value;
data_dict["lobby_data"] = key_value_dict;
data_dict["is_private"] = p_is_private;
data_dict["id"] = id;
command["data"] = data_dict;
Array command_array;
Ref<LobbyResponse> 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::LobbyResponse> LobbyClient::lobby_data(const Dictionary &p_lobby_data, bool p_is_private) {
String id = _increment_counter();
Dictionary command;
Expand Down Expand Up @@ -567,7 +597,7 @@ void LobbyClient::_receive_data(const Dictionary &p_dict) {
Dictionary lobby_dict = data_dict.get("lobby", Dictionary());
Ref<LobbyInfo> lobby_info = Ref<LobbyInfo>(memnew(LobbyInfo));
lobby_info->set_dict(lobby_dict);
if (lobby_info->get_id() == lobby->get_id()) {
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")) {
Expand Down
12 changes: 11 additions & 1 deletion modules/blazium_sdk/lobby/lobby_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,19 @@ class LobbyClient : public BlaziumClient {
Ref<LobbyResponse> lobby_call(const String &p_method, const Array &p_args);
Ref<LobbyResponse> lobby_notify(const Variant &p_peer_data);
Ref<LobbyResponse> peer_notify(const Variant &p_peer_data, const String &p_target_peer);

Ref<LobbyResponse> lobby_data(const Dictionary &p_lobby_data, bool p_is_private);
Ref<LobbyResponse> del_lobby_data(const String &p_key, bool p_is_private);
Ref<LobbyResponse> clear_lobby_data(bool p_is_private);

Ref<LobbyResponse> set_peer_data(const Dictionary &p_peer_data, const String &p_target_peer, bool p_is_private);
Ref<LobbyResponse> set_peers_data(const Dictionary &p_peer_data, bool p_is_private);
Ref<LobbyResponse> del_peer_data(const String &p_key, const String &p_target_peer, bool p_is_private);
Ref<LobbyResponse> clear_peer_data(const Dictionary &p_peer_data, bool p_is_private);

Ref<LobbyResponse> set_peer_data(const Dictionary &p_peer_data, const String &p_target_peer, bool p_is_private);
Ref<LobbyResponse> del_peer_data(const String &p_key, const String &p_target_peer, bool p_is_private);
Ref<LobbyResponse> clear_peers_data(const Dictionary &p_peer_data, bool p_is_private);


LobbyClient();
~LobbyClient();
Expand Down

0 comments on commit a0e8680

Please sign in to comment.