[Net] Rename NetworkedMultiplayerPeer to MultiplayerPeer.
This commit is contained in:
parent
72240084ca
commit
88d68346ee
|
@ -149,7 +149,7 @@ _FORCE_INLINE_ bool _can_call_mode(Node *p_node, MultiplayerAPI::RPCMode mode, i
|
|||
}
|
||||
|
||||
void MultiplayerAPI::poll() {
|
||||
if (!network_peer.is_valid() || network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED) {
|
||||
if (!network_peer.is_valid() || network_peer->get_connection_status() == MultiplayerPeer::CONNECTION_DISCONNECTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -196,13 +196,13 @@ Node *MultiplayerAPI::get_root_node() {
|
|||
return root_node;
|
||||
}
|
||||
|
||||
void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_peer) {
|
||||
void MultiplayerAPI::set_network_peer(const Ref<MultiplayerPeer> &p_peer) {
|
||||
if (p_peer == network_peer) {
|
||||
return; // Nothing to do
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_MSG(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED,
|
||||
"Supplied NetworkedMultiplayerPeer must be connecting or connected.");
|
||||
ERR_FAIL_COND_MSG(p_peer.is_valid() && p_peer->get_connection_status() == MultiplayerPeer::CONNECTION_DISCONNECTED,
|
||||
"Supplied MultiplayerPeer must be connecting or connected.");
|
||||
|
||||
if (network_peer.is_valid()) {
|
||||
network_peer->disconnect("peer_connected", callable_mp(this, &MultiplayerAPI::_add_peer));
|
||||
|
@ -224,7 +224,7 @@ void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_pee
|
|||
}
|
||||
}
|
||||
|
||||
Ref<NetworkedMultiplayerPeer> MultiplayerAPI::get_network_peer() const {
|
||||
Ref<MultiplayerPeer> MultiplayerAPI::get_network_peer() const {
|
||||
return network_peer;
|
||||
}
|
||||
|
||||
|
@ -513,7 +513,7 @@ void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet,
|
|||
packet.write[1] = valid_rpc_checksum;
|
||||
encode_cstring(pname.get_data(), &packet.write[2]);
|
||||
|
||||
network_peer->set_transfer_mode(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
|
||||
network_peer->set_transfer_mode(MultiplayerPeer::TRANSFER_MODE_RELIABLE);
|
||||
network_peer->set_target_peer(p_from);
|
||||
network_peer->put_packet(packet.ptr(), packet.size());
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ bool MultiplayerAPI::_send_confirm_path(Node *p_node, NodePath p_path, PathSentC
|
|||
|
||||
for (List<int>::Element *E = peers_to_add.front(); E; E = E->next()) {
|
||||
network_peer->set_target_peer(E->get()); // To all of you.
|
||||
network_peer->set_transfer_mode(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
|
||||
network_peer->set_transfer_mode(MultiplayerPeer::TRANSFER_MODE_RELIABLE);
|
||||
network_peer->put_packet(packet.ptr(), packet.size());
|
||||
|
||||
psc->confirmed_peers.insert(E->get(), false); // Insert into confirmed, but as false since it was not confirmed.
|
||||
|
@ -760,9 +760,9 @@ Error MultiplayerAPI::_decode_and_decompress_variant(Variant &r_variant, const u
|
|||
void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, uint16_t p_rpc_id, const RPCConfig &p_config, const StringName &p_name, const Variant **p_arg, int p_argcount) {
|
||||
ERR_FAIL_COND_MSG(network_peer.is_null(), "Attempt to remote call/set when networking is not active in SceneTree.");
|
||||
|
||||
ERR_FAIL_COND_MSG(network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_CONNECTING, "Attempt to remote call/set when networking is not connected yet in SceneTree.");
|
||||
ERR_FAIL_COND_MSG(network_peer->get_connection_status() == MultiplayerPeer::CONNECTION_CONNECTING, "Attempt to remote call/set when networking is not connected yet in SceneTree.");
|
||||
|
||||
ERR_FAIL_COND_MSG(network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED, "Attempt to remote call/set when networking is disconnected.");
|
||||
ERR_FAIL_COND_MSG(network_peer->get_connection_status() == MultiplayerPeer::CONNECTION_DISCONNECTED, "Attempt to remote call/set when networking is disconnected.");
|
||||
|
||||
ERR_FAIL_COND_MSG(p_argcount > 255, "Too many arguments >255.");
|
||||
|
||||
|
@ -974,7 +974,7 @@ void MultiplayerAPI::_server_disconnected() {
|
|||
void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) {
|
||||
ERR_FAIL_COND_MSG(!network_peer.is_valid(), "Trying to call an RPC while no network peer is active.");
|
||||
ERR_FAIL_COND_MSG(!p_node->is_inside_tree(), "Trying to call an RPC on a node which is not inside SceneTree.");
|
||||
ERR_FAIL_COND_MSG(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, "Trying to call an RPC via a network peer which is not connected.");
|
||||
ERR_FAIL_COND_MSG(network_peer->get_connection_status() != MultiplayerPeer::CONNECTION_CONNECTED, "Trying to call an RPC via a network peer which is not connected.");
|
||||
|
||||
int node_id = network_peer->get_unique_id();
|
||||
bool skip_rpc = node_id == p_peer_id;
|
||||
|
@ -1033,10 +1033,10 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const
|
|||
ERR_FAIL_COND_MSG(skip_rpc && !(call_local_native || call_local_script), "RPC '" + p_method + "' on yourself is not allowed by selected mode.");
|
||||
}
|
||||
|
||||
Error MultiplayerAPI::send_bytes(Vector<uint8_t> p_data, int p_to, NetworkedMultiplayerPeer::TransferMode p_mode) {
|
||||
Error MultiplayerAPI::send_bytes(Vector<uint8_t> p_data, int p_to, MultiplayerPeer::TransferMode p_mode) {
|
||||
ERR_FAIL_COND_V_MSG(p_data.size() < 1, ERR_INVALID_DATA, "Trying to send an empty raw packet.");
|
||||
ERR_FAIL_COND_V_MSG(!network_peer.is_valid(), ERR_UNCONFIGURED, "Trying to send a raw packet while no network peer is active.");
|
||||
ERR_FAIL_COND_V_MSG(network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED, "Trying to send a raw packet via a network peer which is not connected.");
|
||||
ERR_FAIL_COND_V_MSG(network_peer->get_connection_status() != MultiplayerPeer::CONNECTION_CONNECTED, ERR_UNCONFIGURED, "Trying to send a raw packet via a network peer which is not connected.");
|
||||
|
||||
MAKE_ROOM(p_data.size() + 1);
|
||||
const uint8_t *r = p_data.ptr();
|
||||
|
@ -1105,7 +1105,7 @@ bool MultiplayerAPI::is_object_decoding_allowed() const {
|
|||
void MultiplayerAPI::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_root_node", "node"), &MultiplayerAPI::set_root_node);
|
||||
ClassDB::bind_method(D_METHOD("get_root_node"), &MultiplayerAPI::get_root_node);
|
||||
ClassDB::bind_method(D_METHOD("send_bytes", "bytes", "id", "mode"), &MultiplayerAPI::send_bytes, DEFVAL(NetworkedMultiplayerPeer::TARGET_PEER_BROADCAST), DEFVAL(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE));
|
||||
ClassDB::bind_method(D_METHOD("send_bytes", "bytes", "id", "mode"), &MultiplayerAPI::send_bytes, DEFVAL(MultiplayerPeer::TARGET_PEER_BROADCAST), DEFVAL(MultiplayerPeer::TRANSFER_MODE_RELIABLE));
|
||||
ClassDB::bind_method(D_METHOD("has_network_peer"), &MultiplayerAPI::has_network_peer);
|
||||
ClassDB::bind_method(D_METHOD("get_network_peer"), &MultiplayerAPI::get_network_peer);
|
||||
ClassDB::bind_method(D_METHOD("get_network_unique_id"), &MultiplayerAPI::get_network_unique_id);
|
||||
|
@ -1123,7 +1123,7 @@ void MultiplayerAPI::_bind_methods() {
|
|||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_object_decoding"), "set_allow_object_decoding", "is_object_decoding_allowed");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", PROPERTY_USAGE_NONE), "set_network_peer", "get_network_peer");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerPeer", PROPERTY_USAGE_NONE), "set_network_peer", "get_network_peer");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "root_node", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_root_node", "get_root_node");
|
||||
ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#ifndef MULTIPLAYER_API_H
|
||||
#define MULTIPLAYER_API_H
|
||||
|
||||
#include "core/io/networked_multiplayer_peer.h"
|
||||
#include "core/io/multiplayer_peer.h"
|
||||
#include "core/object/ref_counted.h"
|
||||
|
||||
class MultiplayerAPI : public RefCounted {
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
struct RPCConfig {
|
||||
StringName name;
|
||||
RPCMode rpc_mode = RPC_MODE_DISABLED;
|
||||
NetworkedMultiplayerPeer::TransferMode transfer_mode = NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE;
|
||||
MultiplayerPeer::TransferMode transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE;
|
||||
int channel = 0;
|
||||
|
||||
bool operator==(RPCConfig const &p_other) const {
|
||||
|
@ -83,7 +83,7 @@ private:
|
|||
Map<int, NodeInfo> nodes;
|
||||
};
|
||||
|
||||
Ref<NetworkedMultiplayerPeer> network_peer;
|
||||
Ref<MultiplayerPeer> network_peer;
|
||||
int rpc_sender_id = 0;
|
||||
Set<int> connected_peers;
|
||||
HashMap<NodePath, PathSentCache> path_send_cache;
|
||||
|
@ -132,9 +132,9 @@ public:
|
|||
void clear();
|
||||
void set_root_node(Node *p_node);
|
||||
Node *get_root_node();
|
||||
void set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_peer);
|
||||
Ref<NetworkedMultiplayerPeer> get_network_peer() const;
|
||||
Error send_bytes(Vector<uint8_t> p_data, int p_to = NetworkedMultiplayerPeer::TARGET_PEER_BROADCAST, NetworkedMultiplayerPeer::TransferMode p_mode = NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
|
||||
void set_network_peer(const Ref<MultiplayerPeer> &p_peer);
|
||||
Ref<MultiplayerPeer> get_network_peer() const;
|
||||
Error send_bytes(Vector<uint8_t> p_data, int p_to = MultiplayerPeer::TARGET_PEER_BROADCAST, MultiplayerPeer::TransferMode p_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE);
|
||||
|
||||
// Called by Node.rpc
|
||||
void rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* networked_multiplayer_peer.cpp */
|
||||
/* multiplayer_peer.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,22 +28,22 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "networked_multiplayer_peer.h"
|
||||
#include "multiplayer_peer.h"
|
||||
|
||||
void NetworkedMultiplayerPeer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_transfer_mode", "mode"), &NetworkedMultiplayerPeer::set_transfer_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_transfer_mode"), &NetworkedMultiplayerPeer::get_transfer_mode);
|
||||
ClassDB::bind_method(D_METHOD("set_target_peer", "id"), &NetworkedMultiplayerPeer::set_target_peer);
|
||||
void MultiplayerPeer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_transfer_mode", "mode"), &MultiplayerPeer::set_transfer_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_transfer_mode"), &MultiplayerPeer::get_transfer_mode);
|
||||
ClassDB::bind_method(D_METHOD("set_target_peer", "id"), &MultiplayerPeer::set_target_peer);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_packet_peer"), &NetworkedMultiplayerPeer::get_packet_peer);
|
||||
ClassDB::bind_method(D_METHOD("get_packet_peer"), &MultiplayerPeer::get_packet_peer);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("poll"), &NetworkedMultiplayerPeer::poll);
|
||||
ClassDB::bind_method(D_METHOD("poll"), &MultiplayerPeer::poll);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_connection_status"), &NetworkedMultiplayerPeer::get_connection_status);
|
||||
ClassDB::bind_method(D_METHOD("get_unique_id"), &NetworkedMultiplayerPeer::get_unique_id);
|
||||
ClassDB::bind_method(D_METHOD("get_connection_status"), &MultiplayerPeer::get_connection_status);
|
||||
ClassDB::bind_method(D_METHOD("get_unique_id"), &MultiplayerPeer::get_unique_id);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_refuse_new_connections", "enable"), &NetworkedMultiplayerPeer::set_refuse_new_connections);
|
||||
ClassDB::bind_method(D_METHOD("is_refusing_new_connections"), &NetworkedMultiplayerPeer::is_refusing_new_connections);
|
||||
ClassDB::bind_method(D_METHOD("set_refuse_new_connections", "enable"), &MultiplayerPeer::set_refuse_new_connections);
|
||||
ClassDB::bind_method(D_METHOD("is_refusing_new_connections"), &MultiplayerPeer::is_refusing_new_connections);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_connections"), "set_refuse_new_connections", "is_refusing_new_connections");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "transfer_mode", PROPERTY_HINT_ENUM, "Unreliable,Unreliable Ordered,Reliable"), "set_transfer_mode", "get_transfer_mode");
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* networked_multiplayer_peer.h */
|
||||
/* multiplayer_peer.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -33,8 +33,8 @@
|
|||
|
||||
#include "core/io/packet_peer.h"
|
||||
|
||||
class NetworkedMultiplayerPeer : public PacketPeer {
|
||||
GDCLASS(NetworkedMultiplayerPeer, PacketPeer);
|
||||
class MultiplayerPeer : public PacketPeer {
|
||||
GDCLASS(MultiplayerPeer, PacketPeer);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -73,10 +73,10 @@ public:
|
|||
|
||||
virtual ConnectionStatus get_connection_status() const = 0;
|
||||
|
||||
NetworkedMultiplayerPeer() {}
|
||||
MultiplayerPeer() {}
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::TransferMode)
|
||||
VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::ConnectionStatus)
|
||||
VARIANT_ENUM_CAST(MultiplayerPeer::TransferMode)
|
||||
VARIANT_ENUM_CAST(MultiplayerPeer::ConnectionStatus)
|
||||
|
||||
#endif // NETWORKED_MULTIPLAYER_PEER_H
|
|
@ -48,7 +48,7 @@
|
|||
#include "core/io/json.h"
|
||||
#include "core/io/marshalls.h"
|
||||
#include "core/io/multiplayer_api.h"
|
||||
#include "core/io/networked_multiplayer_peer.h"
|
||||
#include "core/io/multiplayer_peer.h"
|
||||
#include "core/io/packed_data_container.h"
|
||||
#include "core/io/packet_peer.h"
|
||||
#include "core/io/packet_peer_dtls.h"
|
||||
|
@ -188,7 +188,7 @@ void register_core_types() {
|
|||
resource_format_loader_crypto.instantiate();
|
||||
ResourceLoader::add_resource_format_loader(resource_format_loader_crypto);
|
||||
|
||||
ClassDB::register_virtual_class<NetworkedMultiplayerPeer>();
|
||||
ClassDB::register_virtual_class<MultiplayerPeer>();
|
||||
ClassDB::register_class<MultiplayerAPI>();
|
||||
ClassDB::register_class<MainLoop>();
|
||||
ClassDB::register_class<Translation>();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
High-level multiplayer API.
|
||||
</brief_description>
|
||||
<description>
|
||||
This class implements most of the logic behind the high-level multiplayer API. See also [NetworkedMultiplayerPeer].
|
||||
This class implements most of the logic behind the high-level multiplayer API. See also [MultiplayerPeer].
|
||||
By default, [SceneTree] has a reference to this class that is used to provide multiplayer capabilities (i.e. RPC/RSET) across the whole scene.
|
||||
It is possible to override the MultiplayerAPI instance used by specific Nodes by setting the [member Node.custom_multiplayer] property, effectively allowing to run both client and server in the same scene.
|
||||
[b]Note:[/b] The high-level multiplayer API protocol is an implementation detail and isn't meant to be used by non-Godot servers. It may change without notice.
|
||||
|
@ -70,10 +70,10 @@
|
|||
</argument>
|
||||
<argument index="1" name="id" type="int" default="0">
|
||||
</argument>
|
||||
<argument index="2" name="mode" type="int" enum="NetworkedMultiplayerPeer.TransferMode" default="2">
|
||||
<argument index="2" name="mode" type="int" enum="MultiplayerPeer.TransferMode" default="2">
|
||||
</argument>
|
||||
<description>
|
||||
Sends the given raw [code]bytes[/code] to a specific peer identified by [code]id[/code] (see [method NetworkedMultiplayerPeer.set_target_peer]). Default ID is [code]0[/code], i.e. broadcast to all peers.
|
||||
Sends the given raw [code]bytes[/code] to a specific peer identified by [code]id[/code] (see [method MultiplayerPeer.set_target_peer]). Default ID is [code]0[/code], i.e. broadcast to all peers.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
|
@ -82,7 +82,7 @@
|
|||
If [code]true[/code], the MultiplayerAPI will allow encoding and decoding of object during RPCs/RSETs.
|
||||
[b]Warning:[/b] Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
|
||||
</member>
|
||||
<member name="network_peer" type="NetworkedMultiplayerPeer" setter="set_network_peer" getter="get_network_peer">
|
||||
<member name="network_peer" type="MultiplayerPeer" setter="set_network_peer" getter="get_network_peer">
|
||||
The peer object to handle the RPC system (effectively enabling networking when set). Depending on the peer itself, the MultiplayerAPI will become a network server (check with [method is_network_server]) and will set root node's network mode to master, or it will become a regular peer with root node set to puppet. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to MultiplayerAPI's signals.
|
||||
</member>
|
||||
<member name="refuse_new_network_connections" type="bool" setter="set_refuse_new_network_connections" getter="is_refusing_new_network_connections" default="false">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NetworkedMultiplayerPeer" inherits="PacketPeer" version="4.0">
|
||||
<class name="MultiplayerPeer" inherits="PacketPeer" version="4.0">
|
||||
<brief_description>
|
||||
A high-level network interface to simplify multiplayer interactions.
|
||||
</brief_description>
|
||||
|
@ -13,7 +13,7 @@
|
|||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_connection_status" qualifiers="const">
|
||||
<return type="int" enum="NetworkedMultiplayerPeer.ConnectionStatus">
|
||||
<return type="int" enum="MultiplayerPeer.ConnectionStatus">
|
||||
</return>
|
||||
<description>
|
||||
Returns the current state of the connection. See [enum ConnectionStatus].
|
||||
|
@ -23,14 +23,14 @@
|
|||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Returns the ID of the [NetworkedMultiplayerPeer] who sent the most recent packet.
|
||||
Returns the ID of the [MultiplayerPeer] who sent the most recent packet.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_unique_id" qualifiers="const">
|
||||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Returns the ID of this [NetworkedMultiplayerPeer].
|
||||
Returns the ID of this [MultiplayerPeer].
|
||||
</description>
|
||||
</method>
|
||||
<method name="poll">
|
||||
|
@ -53,9 +53,9 @@
|
|||
</methods>
|
||||
<members>
|
||||
<member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" default="true">
|
||||
If [code]true[/code], this [NetworkedMultiplayerPeer] refuses new connections.
|
||||
If [code]true[/code], this [MultiplayerPeer] refuses new connections.
|
||||
</member>
|
||||
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" enum="NetworkedMultiplayerPeer.TransferMode" default="0">
|
||||
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" enum="MultiplayerPeer.TransferMode" default="0">
|
||||
The manner in which to send packets to the [code]target_peer[/code]. See [enum TransferMode].
|
||||
</member>
|
||||
</members>
|
|
@ -670,12 +670,12 @@
|
|||
</argument>
|
||||
<argument index="1" name="rpc_mode" type="int" enum="MultiplayerAPI.RPCMode">
|
||||
</argument>
|
||||
<argument index="2" name="transfer_mode" type="int" enum="NetworkedMultiplayerPeer.TransferMode" default="2">
|
||||
<argument index="2" name="transfer_mode" type="int" enum="MultiplayerPeer.TransferMode" default="2">
|
||||
</argument>
|
||||
<argument index="3" name="channel" type="int" default="0">
|
||||
</argument>
|
||||
<description>
|
||||
Changes the RPC mode for the given [code]method[/code] to the given [code]rpc_mode[/code], optionally specifying the [code]transfer_mode[/code] and [code]channel[/code] (on supported peers). See [enum MultiplayerAPI.RPCMode] and [enum NetworkedMultiplayerPeer.TransferMode]. An alternative is annotating methods and properties with the corresponding keywords ([code]remote[/code], [code]master[/code], [code]puppet[/code], [code]remotesync[/code], [code]mastersync[/code], [code]puppetsync[/code]). By default, methods are not exposed to networking (and RPCs).
|
||||
Changes the RPC mode for the given [code]method[/code] to the given [code]rpc_mode[/code], optionally specifying the [code]transfer_mode[/code] and [code]channel[/code] (on supported peers). See [enum MultiplayerAPI.RPCMode] and [enum MultiplayerPeer.TransferMode]. An alternative is annotating methods and properties with the corresponding keywords ([code]remote[/code], [code]master[/code], [code]puppet[/code], [code]remotesync[/code], [code]mastersync[/code], [code]puppetsync[/code]). By default, methods are not exposed to networking (and RPCs).
|
||||
</description>
|
||||
</method>
|
||||
<method name="rpc_id" qualifiers="vararg">
|
||||
|
@ -686,7 +686,7 @@
|
|||
<argument index="1" name="method" type="StringName">
|
||||
</argument>
|
||||
<description>
|
||||
Sends a [method rpc] to a specific peer identified by [code]peer_id[/code] (see [method NetworkedMultiplayerPeer.set_target_peer]). Returns an empty [Variant].
|
||||
Sends a [method rpc] to a specific peer identified by [code]peer_id[/code] (see [method MultiplayerPeer.set_target_peer]). Returns an empty [Variant].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_display_folded">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="NetworkedMultiplayerENet" inherits="NetworkedMultiplayerPeer" version="4.0">
|
||||
<class name="NetworkedMultiplayerENet" inherits="MultiplayerPeer" version="4.0">
|
||||
<brief_description>
|
||||
PacketPeer implementation using the [url=http://enet.bespin.org/index.html]ENet[/url] library.
|
||||
</brief_description>
|
||||
|
@ -150,7 +150,7 @@
|
|||
</methods>
|
||||
<members>
|
||||
<member name="always_ordered" type="bool" setter="set_always_ordered" getter="is_always_ordered" default="false">
|
||||
Enforce ordered packets when using [constant NetworkedMultiplayerPeer.TRANSFER_MODE_UNRELIABLE] (thus behaving similarly to [constant NetworkedMultiplayerPeer.TRANSFER_MODE_UNRELIABLE_ORDERED]). This is the only way to use ordering with the RPC system.
|
||||
Enforce ordered packets when using [constant MultiplayerPeer.TRANSFER_MODE_UNRELIABLE] (thus behaving similarly to [constant MultiplayerPeer.TRANSFER_MODE_UNRELIABLE_ORDERED]). This is the only way to use ordering with the RPC system.
|
||||
</member>
|
||||
<member name="channel_count" type="int" setter="set_channel_count" getter="get_channel_count" default="3">
|
||||
The number of channels to be used by ENet. Channels are used to separate different kinds of data. In reliable or ordered mode, for example, the packet delivery order is ensured on a per-channel basis. This is done to combat latency and reduces ordering restrictions on packets. The delivery status of a packet in one channel won't stall the delivery of other packets in another channel.
|
||||
|
@ -168,7 +168,7 @@
|
|||
<member name="transfer_channel" type="int" setter="set_transfer_channel" getter="get_transfer_channel" default="-1">
|
||||
Set the default channel to be used to transfer data. By default, this value is [code]-1[/code] which means that ENet will only use 2 channels: one for reliable packets, and one for unreliable packets. The channel [code]0[/code] is reserved and cannot be used. Setting this member to any value between [code]0[/code] and [member channel_count] (excluded) will force ENet to use that channel for sending data. See [member channel_count] for more information about ENet channels.
|
||||
</member>
|
||||
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="NetworkedMultiplayerPeer.TransferMode" default="2" />
|
||||
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="MultiplayerPeer.TransferMode" default="2" />
|
||||
<member name="use_dtls" type="bool" setter="set_dtls_enabled" getter="is_dtls_enabled" default="false">
|
||||
When enabled, the client or server created by this peer, will use [PacketPeerDTLS] instead of raw UDP sockets for communicating with the remote peer. This will make the communication encrypted with DTLS at the cost of higher resource usage and potentially larger packet size.
|
||||
Note: When creating a DTLS server, make sure you setup the key/certificate pair via [method set_dtls_key] and [method set_dtls_certificate]. For DTLS clients, have a look at the [member dtls_verify] option, and configure the certificate accordingly via [method set_dtls_certificate].
|
||||
|
|
|
@ -37,7 +37,7 @@ void NetworkedMultiplayerENet::set_transfer_mode(TransferMode p_mode) {
|
|||
transfer_mode = p_mode;
|
||||
}
|
||||
|
||||
NetworkedMultiplayerPeer::TransferMode NetworkedMultiplayerENet::get_transfer_mode() const {
|
||||
MultiplayerPeer::TransferMode NetworkedMultiplayerENet::get_transfer_mode() const {
|
||||
return transfer_mode;
|
||||
}
|
||||
|
||||
|
@ -604,7 +604,7 @@ void NetworkedMultiplayerENet::_pop_current_packet() {
|
|||
}
|
||||
}
|
||||
|
||||
NetworkedMultiplayerPeer::ConnectionStatus NetworkedMultiplayerENet::get_connection_status() const {
|
||||
MultiplayerPeer::ConnectionStatus NetworkedMultiplayerENet::get_connection_status() const {
|
||||
return connection_status;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
|
||||
#include "core/crypto/crypto.h"
|
||||
#include "core/io/compression.h"
|
||||
#include "core/io/networked_multiplayer_peer.h"
|
||||
#include "core/io/multiplayer_peer.h"
|
||||
|
||||
#include <enet/enet.h>
|
||||
|
||||
class NetworkedMultiplayerENet : public NetworkedMultiplayerPeer {
|
||||
GDCLASS(NetworkedMultiplayerENet, NetworkedMultiplayerPeer);
|
||||
class NetworkedMultiplayerENet : public MultiplayerPeer {
|
||||
GDCLASS(NetworkedMultiplayerENet, MultiplayerPeer);
|
||||
|
||||
public:
|
||||
enum CompressionMode {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="MultiplayerPeerGDNative" inherits="NetworkedMultiplayerPeer" version="4.0">
|
||||
<class name="MultiplayerPeerGDNative" inherits="MultiplayerPeer" version="4.0">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef struct {
|
|||
godot_int (*get_available_packet_count)(const void *);
|
||||
godot_int (*get_max_packet_size)(const void *);
|
||||
|
||||
/* This is NetworkedMultiplayerPeer */
|
||||
/* This is MultiplayerPeer */
|
||||
void (*set_transfer_mode)(void *, godot_int);
|
||||
godot_int (*get_transfer_mode)(const void *);
|
||||
// 0 = broadcast, 1 = server, <0 = all but abs(value)
|
||||
|
|
|
@ -61,13 +61,13 @@ int MultiplayerPeerGDNative::get_available_packet_count() const {
|
|||
return interface->get_available_packet_count(interface->data);
|
||||
}
|
||||
|
||||
/* NetworkedMultiplayerPeer */
|
||||
/* MultiplayerPeer */
|
||||
void MultiplayerPeerGDNative::set_transfer_mode(TransferMode p_mode) {
|
||||
ERR_FAIL_COND(interface == nullptr);
|
||||
interface->set_transfer_mode(interface->data, (godot_int)p_mode);
|
||||
}
|
||||
|
||||
NetworkedMultiplayerPeer::TransferMode MultiplayerPeerGDNative::get_transfer_mode() const {
|
||||
MultiplayerPeer::TransferMode MultiplayerPeerGDNative::get_transfer_mode() const {
|
||||
ERR_FAIL_COND_V(interface == nullptr, TRANSFER_MODE_UNRELIABLE);
|
||||
return (TransferMode)interface->get_transfer_mode(interface->data);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ bool MultiplayerPeerGDNative::is_refusing_new_connections() const {
|
|||
return interface->is_refusing_new_connections(interface->data);
|
||||
}
|
||||
|
||||
NetworkedMultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connection_status() const {
|
||||
MultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connection_status() const {
|
||||
ERR_FAIL_COND_V(interface == nullptr, CONNECTION_DISCONNECTED);
|
||||
return (ConnectionStatus)interface->get_connection_status(interface->data);
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
#ifndef MULTIPLAYER_PEER_GDNATIVE_H
|
||||
#define MULTIPLAYER_PEER_GDNATIVE_H
|
||||
|
||||
#include "core/io/networked_multiplayer_peer.h"
|
||||
#include "core/io/multiplayer_peer.h"
|
||||
#include "modules/gdnative/gdnative.h"
|
||||
#include "modules/gdnative/include/net/godot_net.h"
|
||||
|
||||
class MultiplayerPeerGDNative : public NetworkedMultiplayerPeer {
|
||||
GDCLASS(MultiplayerPeerGDNative, NetworkedMultiplayerPeer);
|
||||
class MultiplayerPeerGDNative : public MultiplayerPeer {
|
||||
GDCLASS(MultiplayerPeerGDNative, MultiplayerPeer);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
virtual int get_max_packet_size() const override;
|
||||
virtual int get_available_packet_count() const override;
|
||||
|
||||
/* Specific to NetworkedMultiplayerPeer */
|
||||
/* Specific to MultiplayerPeer */
|
||||
virtual void set_transfer_mode(TransferMode p_mode) override;
|
||||
virtual TransferMode get_transfer_mode() const override;
|
||||
virtual void set_target_peer(int p_peer_id) override;
|
||||
|
|
|
@ -1170,7 +1170,7 @@ void GDScript::_init_rpc_methods_properties() {
|
|||
nd.name = E->key();
|
||||
nd.rpc_mode = E->get()->get_rpc_mode();
|
||||
// TODO
|
||||
nd.transfer_mode = NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE;
|
||||
nd.transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE;
|
||||
nd.channel = 0;
|
||||
if (-1 == rpc_functions.find(nd)) {
|
||||
rpc_functions.push_back(nd);
|
||||
|
|
|
@ -3038,7 +3038,7 @@ void CSharpScript::update_script_class_info(Ref<CSharpScript> p_script) {
|
|||
nd.name = methods[i]->get_name();
|
||||
nd.rpc_mode = mode;
|
||||
// TODO Transfer mode, channel
|
||||
nd.transfer_mode = NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE;
|
||||
nd.transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE;
|
||||
nd.channel = 0;
|
||||
if (-1 == p_script->rpc_functions.find(nd)) {
|
||||
p_script->rpc_functions.push_back(nd);
|
||||
|
|
|
@ -1025,7 +1025,7 @@ void VisualScript::_set_data(const Dictionary &p_data) {
|
|||
MultiplayerAPI::RPCConfig nd;
|
||||
nd.name = E->get();
|
||||
nd.rpc_mode = vsf->get_rpc_mode();
|
||||
nd.transfer_mode = NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE; // TODO
|
||||
nd.transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE; // TODO
|
||||
if (rpc_functions.find(nd) == -1) {
|
||||
rpc_functions.push_back(nd);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="WebRTCMultiplayer" inherits="NetworkedMultiplayerPeer" version="4.0">
|
||||
<class name="WebRTCMultiplayer" inherits="MultiplayerPeer" version="4.0">
|
||||
<brief_description>
|
||||
A simple interface to create a peer-to-peer mesh network composed of [WebRTCPeerConnection] that is compatible with the [MultiplayerAPI].
|
||||
</brief_description>
|
||||
<description>
|
||||
This class constructs a full mesh of [WebRTCPeerConnection] (one connection for each peer) that can be used as a [member MultiplayerAPI.network_peer].
|
||||
You can add each [WebRTCPeerConnection] via [method add_peer] or remove them via [method remove_peer]. Peers must be added in [constant WebRTCPeerConnection.STATE_NEW] state to allow it to create the appropriate channels. This class will not create offers nor set descriptions, it will only poll them, and notify connections and disconnections.
|
||||
[signal NetworkedMultiplayerPeer.connection_succeeded] and [signal NetworkedMultiplayerPeer.server_disconnected] will not be emitted unless [code]server_compatibility[/code] is [code]true[/code] in [method initialize]. Beside that data transfer works like in a [NetworkedMultiplayerPeer].
|
||||
[signal MultiplayerPeer.connection_succeeded] and [signal MultiplayerPeer.server_disconnected] will not be emitted unless [code]server_compatibility[/code] is [code]true[/code] in [method initialize]. Beside that data transfer works like in a [MultiplayerPeer].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
@ -66,8 +66,8 @@
|
|||
</argument>
|
||||
<description>
|
||||
Initialize the multiplayer peer with the given [code]peer_id[/code] (must be between 1 and 2147483647).
|
||||
If [code]server_compatibilty[/code] is [code]false[/code] (default), the multiplayer peer will be immediately in state [constant NetworkedMultiplayerPeer.CONNECTION_CONNECTED] and [signal NetworkedMultiplayerPeer.connection_succeeded] will not be emitted.
|
||||
If [code]server_compatibilty[/code] is [code]true[/code] the peer will suppress all [signal NetworkedMultiplayerPeer.peer_connected] signals until a peer with id [constant NetworkedMultiplayerPeer.TARGET_PEER_SERVER] connects and then emit [signal NetworkedMultiplayerPeer.connection_succeeded]. After that the signal [signal NetworkedMultiplayerPeer.peer_connected] will be emitted for every already connected peer, and any new peer that might connect. If the server peer disconnects after that, signal [signal NetworkedMultiplayerPeer.server_disconnected] will be emitted and state will become [constant NetworkedMultiplayerPeer.CONNECTION_CONNECTED].
|
||||
If [code]server_compatibilty[/code] is [code]false[/code] (default), the multiplayer peer will be immediately in state [constant MultiplayerPeer.CONNECTION_CONNECTED] and [signal MultiplayerPeer.connection_succeeded] will not be emitted.
|
||||
If [code]server_compatibilty[/code] is [code]true[/code] the peer will suppress all [signal MultiplayerPeer.peer_connected] signals until a peer with id [constant MultiplayerPeer.TARGET_PEER_SERVER] connects and then emit [signal MultiplayerPeer.connection_succeeded]. After that the signal [signal MultiplayerPeer.peer_connected] will be emitted for every already connected peer, and any new peer that might connect. If the server peer disconnects after that, signal [signal MultiplayerPeer.server_disconnected] will be emitted and state will become [constant MultiplayerPeer.CONNECTION_CONNECTED].
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_peer">
|
||||
|
@ -76,13 +76,13 @@
|
|||
<argument index="0" name="peer_id" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Remove the peer with given [code]peer_id[/code] from the mesh. If the peer was connected, and [signal NetworkedMultiplayerPeer.peer_connected] was emitted for it, then [signal NetworkedMultiplayerPeer.peer_disconnected] will be emitted.
|
||||
Remove the peer with given [code]peer_id[/code] from the mesh. If the peer was connected, and [signal MultiplayerPeer.peer_connected] was emitted for it, then [signal MultiplayerPeer.peer_disconnected] will be emitted.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" />
|
||||
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="NetworkedMultiplayerPeer.TransferMode" default="2" />
|
||||
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="MultiplayerPeer.TransferMode" default="2" />
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
|
|
|
@ -47,7 +47,7 @@ void WebRTCMultiplayer::set_transfer_mode(TransferMode p_mode) {
|
|||
transfer_mode = p_mode;
|
||||
}
|
||||
|
||||
NetworkedMultiplayerPeer::TransferMode WebRTCMultiplayer::get_transfer_mode() const {
|
||||
MultiplayerPeer::TransferMode WebRTCMultiplayer::get_transfer_mode() const {
|
||||
return transfer_mode;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ void WebRTCMultiplayer::set_target_peer(int p_peer_id) {
|
|||
target_peer = p_peer_id;
|
||||
}
|
||||
|
||||
/* Returns the ID of the NetworkedMultiplayerPeer who sent the most recent packet: */
|
||||
/* Returns the ID of the MultiplayerPeer who sent the most recent packet: */
|
||||
int WebRTCMultiplayer::get_packet_peer() const {
|
||||
return next_packet_peer;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ bool WebRTCMultiplayer::is_refusing_new_connections() const {
|
|||
return refuse_connections;
|
||||
}
|
||||
|
||||
NetworkedMultiplayerPeer::ConnectionStatus WebRTCMultiplayer::get_connection_status() const {
|
||||
MultiplayerPeer::ConnectionStatus WebRTCMultiplayer::get_connection_status() const {
|
||||
return connection_status;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,11 @@
|
|||
#ifndef WEBRTC_MULTIPLAYER_H
|
||||
#define WEBRTC_MULTIPLAYER_H
|
||||
|
||||
#include "core/io/networked_multiplayer_peer.h"
|
||||
#include "core/io/multiplayer_peer.h"
|
||||
#include "webrtc_peer_connection.h"
|
||||
|
||||
class WebRTCMultiplayer : public NetworkedMultiplayerPeer {
|
||||
GDCLASS(WebRTCMultiplayer, NetworkedMultiplayerPeer);
|
||||
class WebRTCMultiplayer : public MultiplayerPeer {
|
||||
GDCLASS(WebRTCMultiplayer, MultiplayerPeer);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
int get_available_packet_count() const override;
|
||||
int get_max_packet_size() const override;
|
||||
|
||||
// NetworkedMultiplayerPeer
|
||||
// MultiplayerPeer
|
||||
void set_transfer_mode(TransferMode p_mode) override;
|
||||
TransferMode get_transfer_mode() const override;
|
||||
void set_target_peer(int p_peer_id) override;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<description>
|
||||
This class implements a WebSocket client compatible with any RFC 6455-compliant WebSocket server.
|
||||
This client can be optionally used as a network peer for the [MultiplayerAPI].
|
||||
After starting the client ([method connect_to_url]), you will need to [method NetworkedMultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]).
|
||||
After starting the client ([method connect_to_url]), you will need to [method MultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]).
|
||||
You will receive appropriate signals when connecting, disconnecting, or when new data is available.
|
||||
</description>
|
||||
<tutorials>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="WebSocketMultiplayerPeer" inherits="NetworkedMultiplayerPeer" version="4.0">
|
||||
<class name="WebSocketMultiplayerPeer" inherits="MultiplayerPeer" version="4.0">
|
||||
<brief_description>
|
||||
Base class for WebSocket server and client.
|
||||
</brief_description>
|
||||
|
@ -39,7 +39,7 @@
|
|||
</methods>
|
||||
<members>
|
||||
<member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" />
|
||||
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="NetworkedMultiplayerPeer.TransferMode" default="2" />
|
||||
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="MultiplayerPeer.TransferMode" default="2" />
|
||||
</members>
|
||||
<signals>
|
||||
<signal name="peer_packet">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</brief_description>
|
||||
<description>
|
||||
This class implements a WebSocket server that can also support the high-level multiplayer API.
|
||||
After starting the server ([method listen]), you will need to [method NetworkedMultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]). When clients connect, disconnect, or send data, you will receive the appropriate signal.
|
||||
After starting the server ([method listen]), you will need to [method MultiplayerPeer.poll] it at regular intervals (e.g. inside [method Node._process]). When clients connect, disconnect, or send data, you will receive the appropriate signal.
|
||||
[b]Note:[/b] Not available in HTML5 exports.
|
||||
</description>
|
||||
<tutorials>
|
||||
|
|
|
@ -107,7 +107,7 @@ Ref<WebSocketPeer> EMWSClient::get_peer(int p_peer_id) const {
|
|||
return _peer;
|
||||
}
|
||||
|
||||
NetworkedMultiplayerPeer::ConnectionStatus EMWSClient::get_connection_status() const {
|
||||
MultiplayerPeer::ConnectionStatus EMWSClient::get_connection_status() const {
|
||||
if (_peer->is_connected_to_host()) {
|
||||
if (_is_connecting)
|
||||
return CONNECTION_CONNECTING;
|
||||
|
|
|
@ -123,13 +123,13 @@ Error WebSocketMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer
|
|||
}
|
||||
|
||||
//
|
||||
// NetworkedMultiplayerPeer
|
||||
// MultiplayerPeer
|
||||
//
|
||||
void WebSocketMultiplayerPeer::set_transfer_mode(TransferMode p_mode) {
|
||||
// Websocket uses TCP, reliable
|
||||
}
|
||||
|
||||
NetworkedMultiplayerPeer::TransferMode WebSocketMultiplayerPeer::get_transfer_mode() const {
|
||||
MultiplayerPeer::TransferMode WebSocketMultiplayerPeer::get_transfer_mode() const {
|
||||
// Websocket uses TCP, reliable
|
||||
return TRANSFER_MODE_RELIABLE;
|
||||
}
|
||||
|
|
|
@ -32,12 +32,12 @@
|
|||
#define WEBSOCKET_MULTIPLAYER_PEER_H
|
||||
|
||||
#include "core/error/error_list.h"
|
||||
#include "core/io/networked_multiplayer_peer.h"
|
||||
#include "core/io/multiplayer_peer.h"
|
||||
#include "core/templates/list.h"
|
||||
#include "websocket_peer.h"
|
||||
|
||||
class WebSocketMultiplayerPeer : public NetworkedMultiplayerPeer {
|
||||
GDCLASS(WebSocketMultiplayerPeer, NetworkedMultiplayerPeer);
|
||||
class WebSocketMultiplayerPeer : public MultiplayerPeer {
|
||||
GDCLASS(WebSocketMultiplayerPeer, MultiplayerPeer);
|
||||
|
||||
private:
|
||||
Vector<uint8_t> _make_pkt(uint8_t p_type, int32_t p_from, int32_t p_to, const uint8_t *p_data, uint32_t p_data_size);
|
||||
|
@ -78,7 +78,7 @@ protected:
|
|||
int _gen_unique_id() const;
|
||||
|
||||
public:
|
||||
/* NetworkedMultiplayerPeer */
|
||||
/* MultiplayerPeer */
|
||||
void set_transfer_mode(TransferMode p_mode) override;
|
||||
TransferMode get_transfer_mode() const override;
|
||||
void set_target_peer(int p_target_peer) override;
|
||||
|
|
|
@ -121,7 +121,7 @@ void WebSocketServer::set_handshake_timeout(float p_timeout) {
|
|||
handshake_timeout = p_timeout * 1000;
|
||||
}
|
||||
|
||||
NetworkedMultiplayerPeer::ConnectionStatus WebSocketServer::get_connection_status() const {
|
||||
MultiplayerPeer::ConnectionStatus WebSocketServer::get_connection_status() const {
|
||||
if (is_listening()) {
|
||||
return CONNECTION_CONNECTED;
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ Ref<WebSocketPeer> WSLClient::get_peer(int p_peer_id) const {
|
|||
return _peer;
|
||||
}
|
||||
|
||||
NetworkedMultiplayerPeer::ConnectionStatus WSLClient::get_connection_status() const {
|
||||
MultiplayerPeer::ConnectionStatus WSLClient::get_connection_status() const {
|
||||
if (_peer->is_connected_to_host()) {
|
||||
return CONNECTION_CONNECTED;
|
||||
}
|
||||
|
|
|
@ -507,7 +507,7 @@ bool Node::is_network_master() const {
|
|||
|
||||
/***** RPC CONFIG ********/
|
||||
|
||||
uint16_t Node::rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_rpc_mode, NetworkedMultiplayerPeer::TransferMode p_transfer_mode, int p_channel) {
|
||||
uint16_t Node::rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_rpc_mode, MultiplayerPeer::TransferMode p_transfer_mode, int p_channel) {
|
||||
for (int i = 0; i < data.rpc_methods.size(); i++) {
|
||||
if (data.rpc_methods[i].name == p_method) {
|
||||
MultiplayerAPI::RPCConfig &nd = data.rpc_methods.write[i];
|
||||
|
@ -2623,7 +2623,7 @@ void Node::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_multiplayer"), &Node::get_multiplayer);
|
||||
ClassDB::bind_method(D_METHOD("get_custom_multiplayer"), &Node::get_custom_multiplayer);
|
||||
ClassDB::bind_method(D_METHOD("set_custom_multiplayer", "api"), &Node::set_custom_multiplayer);
|
||||
ClassDB::bind_method(D_METHOD("rpc_config", "method", "rpc_mode", "transfer_mode", "channel"), &Node::rpc_config, DEFVAL(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE), DEFVAL(0));
|
||||
ClassDB::bind_method(D_METHOD("rpc_config", "method", "rpc_mode", "transfer_mode", "channel"), &Node::rpc_config, DEFVAL(MultiplayerPeer::TRANSFER_MODE_RELIABLE), DEFVAL(0));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_editor_description", "editor_description"), &Node::set_editor_description);
|
||||
ClassDB::bind_method(D_METHOD("get_editor_description"), &Node::get_editor_description);
|
||||
|
|
|
@ -430,7 +430,7 @@ public:
|
|||
int get_network_master() const;
|
||||
bool is_network_master() const;
|
||||
|
||||
uint16_t rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_rpc_mode, NetworkedMultiplayerPeer::TransferMode p_transfer_mode, int p_channel = 0); // config a local method for RPC
|
||||
uint16_t rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_rpc_mode, MultiplayerPeer::TransferMode p_transfer_mode, int p_channel = 0); // config a local method for RPC
|
||||
Vector<MultiplayerAPI::RPCConfig> get_node_rpc_methods() const;
|
||||
|
||||
void rpc(const StringName &p_method, VARIANT_ARG_LIST); // RPC, honors RPCMode, TransferMode, channel
|
||||
|
|
Loading…
Reference in New Issue