forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add code for lobby call auth add set tags update tags add set tags
- Loading branch information
Showing
12 changed files
with
282 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="AuthoritativeClient" inherits="LobbyClient" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> | ||
<brief_description> | ||
A lobby client that is authoritative. | ||
</brief_description> | ||
<description> | ||
A lobby client that is authoritative. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<methods> | ||
<method name="lobby_call"> | ||
<return type="LobbyCallResponse" /> | ||
<param index="0" name="method" type="String" /> | ||
<param index="1" name="args" type="Array" /> | ||
<description> | ||
Call a method on the server. | ||
</description> | ||
</method> | ||
</methods> | ||
<members> | ||
<member name="server_url" type="String" setter="set_server_url" getter="get_server_url" overrides="LobbyClient" default=""wss://authlobby.blazium.app/connect"" /> | ||
</members> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="LobbyCallResponse" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> | ||
<brief_description> | ||
Response from a lobby call function. | ||
</brief_description> | ||
<description> | ||
Response from a lobby call function. Await on finished to get the [LobbyCallResult]. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<signals> | ||
<signal name="finished"> | ||
<param index="0" name="result" type="LobbyCallResult" /> | ||
<description> | ||
Signal emitted when the request is finished. | ||
</description> | ||
</signal> | ||
</signals> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<class name="LobbyCallResult" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> | ||
<brief_description> | ||
A result from a [LobbyCallResponse]. | ||
</brief_description> | ||
<description> | ||
A result from a [LobbyCallResponse]. | ||
</description> | ||
<tutorials> | ||
</tutorials> | ||
<methods> | ||
<method name="get_result" qualifiers="const"> | ||
<return type="Variant" /> | ||
<description> | ||
Result of the function call. | ||
</description> | ||
</method> | ||
<method name="has_error" qualifiers="const"> | ||
<return type="bool" /> | ||
<description> | ||
Returns true if there is an error. | ||
</description> | ||
</method> | ||
</methods> | ||
<members> | ||
<member name="error" type="String" setter="" getter="get_error" default=""""> | ||
Gets the error message. | ||
</member> | ||
</members> | ||
</class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "authoritative_client.h" | ||
|
||
Ref<AuthoritativeClient::LobbyCallResponse> AuthoritativeClient::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; | ||
command["data"] = data_dict; | ||
Array command_array; | ||
Ref<LobbyCallResponse> response; | ||
response.instantiate(); | ||
command_array.push_back(LobbyClient::LOBBY_CALL); | ||
command_array.push_back(response); | ||
_commands[id] = command_array; | ||
_send_data(command); | ||
return response; | ||
} | ||
|
||
void AuthoritativeClient::_bind_methods() { | ||
ClassDB::bind_method(D_METHOD("lobby_call", "method", "args"), &AuthoritativeClient::lobby_call); | ||
ADD_PROPERTY_DEFAULT("peers", TypedArray<LobbyPeer>()); | ||
ADD_PROPERTY_DEFAULT("peer", Ref<LobbyPeer>()); | ||
ADD_PROPERTY_DEFAULT("lobby", Ref<LobbyInfo>()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/**************************************************************************/ | ||
/* 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_CLIENT_H | ||
#define AUTHORITATIVE_CLIENT_H | ||
|
||
#include "lobby_client.h" | ||
|
||
class AuthoritativeClient : public LobbyClient { | ||
GDCLASS(AuthoritativeClient, LobbyClient); | ||
|
||
public: | ||
class LobbyCallResponse : public RefCounted { | ||
GDCLASS(LobbyCallResponse, RefCounted); | ||
|
||
protected: | ||
static void _bind_methods() { | ||
ADD_SIGNAL(MethodInfo("finished", PropertyInfo(Variant::OBJECT, "result", PROPERTY_HINT_RESOURCE_TYPE, "LobbyCallResult"))); | ||
} | ||
|
||
public: | ||
class LobbyCallResult : public RefCounted { | ||
GDCLASS(LobbyCallResult, RefCounted); | ||
Variant result; | ||
String error; | ||
|
||
protected: | ||
static void _bind_methods() { | ||
ClassDB::bind_method(D_METHOD("has_error"), &LobbyCallResult::has_error); | ||
ClassDB::bind_method(D_METHOD("get_error"), &LobbyCallResult::get_error); | ||
ClassDB::bind_method(D_METHOD("get_result"), &LobbyCallResult::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; } | ||
}; | ||
}; | ||
|
||
protected: | ||
static void _bind_methods(); | ||
|
||
public: | ||
Ref<LobbyCallResponse> lobby_call(const String &p_method, const Array &p_args); | ||
|
||
AuthoritativeClient() { | ||
server_url = "wss://authlobby.blazium.app/connect"; | ||
} | ||
}; | ||
|
||
#endif // AUTHORITATIVE_CLIENT_H |
Oops, something went wrong.