summaryrefslogtreecommitdiff
path: root/modules/enet
diff options
context:
space:
mode:
Diffstat (limited to 'modules/enet')
-rw-r--r--modules/enet/doc_classes/ENetConnection.xml60
-rw-r--r--modules/enet/doc_classes/ENetMultiplayerPeer.xml34
-rw-r--r--modules/enet/doc_classes/ENetPacketPeer.xml40
-rw-r--r--modules/enet/enet_connection.cpp5
-rw-r--r--modules/enet/enet_connection.h5
-rw-r--r--modules/enet/enet_multiplayer_peer.cpp6
-rw-r--r--modules/enet/enet_multiplayer_peer.h12
-rw-r--r--modules/enet/enet_packet_peer.cpp2
-rw-r--r--modules/enet/register_types.cpp12
-rw-r--r--modules/enet/register_types.h6
10 files changed, 105 insertions, 77 deletions
diff --git a/modules/enet/doc_classes/ENetConnection.xml b/modules/enet/doc_classes/ENetConnection.xml
index 14aad0cb39..8c84fe87d7 100644
--- a/modules/enet/doc_classes/ENetConnection.xml
+++ b/modules/enet/doc_classes/ENetConnection.xml
@@ -12,31 +12,31 @@
<methods>
<method name="bandwidth_limit">
<return type="void" />
- <argument index="0" name="in_bandwidth" type="int" default="0" />
- <argument index="1" name="out_bandwidth" type="int" default="0" />
+ <param index="0" name="in_bandwidth" type="int" default="0" />
+ <param index="1" name="out_bandwidth" type="int" default="0" />
<description>
Adjusts the bandwidth limits of a host.
</description>
</method>
<method name="broadcast">
<return type="void" />
- <argument index="0" name="channel" type="int" />
- <argument index="1" name="packet" type="PackedByteArray" />
- <argument index="2" name="flags" type="int" />
+ <param index="0" name="channel" type="int" />
+ <param index="1" name="packet" type="PackedByteArray" />
+ <param index="2" name="flags" type="int" />
<description>
Queues a [code]packet[/code] to be sent to all peers associated with the host over the specified [code]channel[/code]. See [ENetPacketPeer] [code]FLAG_*[/code] constants for available packet flags.
</description>
</method>
<method name="channel_limit">
<return type="void" />
- <argument index="0" name="limit" type="int" />
+ <param index="0" name="limit" type="int" />
<description>
Limits the maximum allowed channels of future incoming connections.
</description>
</method>
<method name="compress">
<return type="void" />
- <argument index="0" name="mode" type="int" enum="ENetConnection.CompressionMode" />
+ <param index="0" name="mode" type="int" enum="ENetConnection.CompressionMode" />
<description>
Sets the compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all.
[b]Note:[/b] Most games' network design involve sending many small packets frequently (smaller than 4 KB each). If in doubt, it is recommended to keep the default compression algorithm as it works best on these small packets.
@@ -45,10 +45,10 @@
</method>
<method name="connect_to_host">
<return type="ENetPacketPeer" />
- <argument index="0" name="address" type="String" />
- <argument index="1" name="port" type="int" />
- <argument index="2" name="channels" type="int" default="0" />
- <argument index="3" name="data" type="int" default="0" />
+ <param index="0" name="address" type="String" />
+ <param index="1" name="port" type="int" />
+ <param index="2" name="channels" type="int" default="0" />
+ <param index="3" name="data" type="int" default="0" />
<description>
Initiates a connection to a foreign [code]address[/code] using the specified [code]port[/code] and allocating the requested [code]channels[/code]. Optional [code]data[/code] can be passed during connection in the form of a 32 bit integer.
[b]Note:[/b] You must call either [method create_host] or [method create_host_bound] before calling this method.
@@ -56,22 +56,22 @@
</method>
<method name="create_host">
<return type="int" enum="Error" />
- <argument index="0" name="max_peers" type="int" default="32" />
- <argument index="1" name="max_channels" type="int" default="0" />
- <argument index="2" name="in_bandwidth" type="int" default="0" />
- <argument index="3" name="out_bandwidth" type="int" default="0" />
+ <param index="0" name="max_peers" type="int" default="32" />
+ <param index="1" name="max_channels" type="int" default="0" />
+ <param index="2" name="in_bandwidth" type="int" default="0" />
+ <param index="3" name="out_bandwidth" type="int" default="0" />
<description>
Create an ENetHost that will allow up to [code]max_peers[/code] connected peers, each allocating up to [code]max_channels[/code] channels, optionally limiting bandwidth to [code]in_bandwidth[/code] and [code]out_bandwidth[/code].
</description>
</method>
<method name="create_host_bound">
<return type="int" enum="Error" />
- <argument index="0" name="bind_address" type="String" />
- <argument index="1" name="bind_port" type="int" />
- <argument index="2" name="max_peers" type="int" default="32" />
- <argument index="3" name="max_channels" type="int" default="0" />
- <argument index="4" name="in_bandwidth" type="int" default="0" />
- <argument index="5" name="out_bandwidth" type="int" default="0" />
+ <param index="0" name="bind_address" type="String" />
+ <param index="1" name="bind_port" type="int" />
+ <param index="2" name="max_peers" type="int" default="32" />
+ <param index="3" name="max_channels" type="int" default="0" />
+ <param index="4" name="in_bandwidth" type="int" default="0" />
+ <param index="5" name="out_bandwidth" type="int" default="0" />
<description>
Create an ENetHost like [method create_host] which is also bound to the given [code]bind_address[/code] and [code]bind_port[/code].
</description>
@@ -84,17 +84,17 @@
</method>
<method name="dtls_client_setup">
<return type="int" enum="Error" />
- <argument index="0" name="certificate" type="X509Certificate" />
- <argument index="1" name="hostname" type="String" />
- <argument index="2" name="verify" type="bool" default="true" />
+ <param index="0" name="certificate" type="X509Certificate" />
+ <param index="1" name="hostname" type="String" />
+ <param index="2" name="verify" type="bool" default="true" />
<description>
Configure this ENetHost to use the custom Godot extension allowing DTLS encryption for ENet clients. Call this before [method connect_to_host] to have ENet connect using DTLS with [code]certificate[/code] and [code]hostname[/code] verification. Verification can be optionally turned off via the [code]verify[/code] parameter.
</description>
</method>
<method name="dtls_server_setup">
<return type="int" enum="Error" />
- <argument index="0" name="key" type="CryptoKey" />
- <argument index="1" name="certificate" type="X509Certificate" />
+ <param index="0" name="key" type="CryptoKey" />
+ <param index="1" name="certificate" type="X509Certificate" />
<description>
Configure this ENetHost to use the custom Godot extension allowing DTLS encryption for ENet servers. Call this right after [method create_host_bound] to have ENet expect peers to connect using DTLS.
</description>
@@ -118,7 +118,7 @@
</description>
</method>
<method name="get_peers">
- <return type="Array" />
+ <return type="ENetPacketPeer[]" />
<description>
Returns the list of peers associated with this host.
[b]Note:[/b] This list might include some peers that are not fully connected or are still being disconnected.
@@ -126,14 +126,14 @@
</method>
<method name="pop_statistic">
<return type="float" />
- <argument index="0" name="statistic" type="int" enum="ENetConnection.HostStatistic" />
+ <param index="0" name="statistic" type="int" enum="ENetConnection.HostStatistic" />
<description>
Returns and resets host statistics. See [enum HostStatistic] for more info.
</description>
</method>
<method name="refuse_new_connections">
<return type="void" />
- <argument index="0" name="refuse" type="bool" />
+ <param index="0" name="refuse" type="bool" />
<description>
Configures the DTLS server to automatically drop new connections.
[b]Note:[/b] This method is only relevant after calling [method dtls_server_setup].
@@ -141,7 +141,7 @@
</method>
<method name="service">
<return type="Array" />
- <argument index="0" name="timeout" type="int" default="0" />
+ <param index="0" name="timeout" type="int" default="0" />
<description>
Waits for events on the host specified and shuttles packets between the host and its peers. The returned [Array] will have 4 elements. An [enum EventType], the [ENetPacketPeer] which generated the event, the event associated data (if any), the event associated channel (if any). If the generated event is [constant EVENT_RECEIVE], the received packet will be queued to the associated [ENetPacketPeer].
Call this function regularly to handle connections, disconnections, and to receive new packets.
diff --git a/modules/enet/doc_classes/ENetMultiplayerPeer.xml b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
index 2ecf6b4122..5181ae76ce 100644
--- a/modules/enet/doc_classes/ENetMultiplayerPeer.xml
+++ b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
@@ -14,8 +14,8 @@
<methods>
<method name="add_mesh_peer">
<return type="int" enum="Error" />
- <argument index="0" name="peer_id" type="int" />
- <argument index="1" name="host" type="ENetConnection" />
+ <param index="0" name="peer_id" type="int" />
+ <param index="1" name="host" type="ENetConnection" />
<description>
Add a new remote peer with the given [code]peer_id[/code] connected to the given [code]host[/code].
[b]Note:[/b] The [code]host[/code] must have exactly one peer in the [constant ENetPacketPeer.STATE_CONNECTED] state.
@@ -23,51 +23,51 @@
</method>
<method name="close_connection">
<return type="void" />
- <argument index="0" name="wait_usec" type="int" default="100" />
+ <param index="0" name="wait_usec" type="int" default="100" />
<description>
Closes the connection. Ignored if no connection is currently established. If this is a server it tries to notify all clients before forcibly disconnecting them. If this is a client it simply closes the connection to the server.
</description>
</method>
<method name="create_client">
<return type="int" enum="Error" />
- <argument index="0" name="address" type="String" />
- <argument index="1" name="port" type="int" />
- <argument index="2" name="channel_count" type="int" default="0" />
- <argument index="3" name="in_bandwidth" type="int" default="0" />
- <argument index="4" name="out_bandwidth" type="int" default="0" />
- <argument index="5" name="local_port" type="int" default="0" />
+ <param index="0" name="address" type="String" />
+ <param index="1" name="port" type="int" />
+ <param index="2" name="channel_count" type="int" default="0" />
+ <param index="3" name="in_bandwidth" type="int" default="0" />
+ <param index="4" name="out_bandwidth" type="int" default="0" />
+ <param index="5" name="local_port" type="int" default="0" />
<description>
Create client that connects to a server at [code]address[/code] using specified [code]port[/code]. The given address needs to be either a fully qualified domain name (e.g. [code]"www.example.com"[/code]) or an IP address in IPv4 or IPv6 format (e.g. [code]"192.168.1.1"[/code]). The [code]port[/code] is the port the server is listening on. The [code]channel_count[/code] parameter can be used to specify the number of ENet channels allocated for the connection. The [code]in_bandwidth[/code] and [code]out_bandwidth[/code] parameters can be used to limit the incoming and outgoing bandwidth to the given number of bytes per second. The default of 0 means unlimited bandwidth. Note that ENet will strategically drop packets on specific sides of a connection between peers to ensure the peer's bandwidth is not overwhelmed. The bandwidth parameters also determine the window size of a connection which limits the amount of reliable packets that may be in transit at any given time. Returns [constant OK] if a client was created, [constant ERR_ALREADY_IN_USE] if this ENetMultiplayerPeer instance already has an open connection (in which case you need to call [method close_connection] first) or [constant ERR_CANT_CREATE] if the client could not be created. If [code]local_port[/code] is specified, the client will also listen to the given port; this is useful for some NAT traversal techniques.
</description>
</method>
<method name="create_mesh">
<return type="int" enum="Error" />
- <argument index="0" name="unique_id" type="int" />
+ <param index="0" name="unique_id" type="int" />
<description>
Initialize this [MultiplayerPeer] in mesh mode. The provided [code]unique_id[/code] will be used as the local peer network unique ID once assigned as the [member MultiplayerAPI.multiplayer_peer]. In the mesh configuration you will need to set up each new peer manually using [ENetConnection] before calling [method add_mesh_peer]. While this technique is more advanced, it allows for better control over the connection process (e.g. when dealing with NAT punch-through) and for better distribution of the network load (which would otherwise be more taxing on the server).
</description>
</method>
<method name="create_server">
<return type="int" enum="Error" />
- <argument index="0" name="port" type="int" />
- <argument index="1" name="max_clients" type="int" default="32" />
- <argument index="2" name="max_channels" type="int" default="0" />
- <argument index="3" name="in_bandwidth" type="int" default="0" />
- <argument index="4" name="out_bandwidth" type="int" default="0" />
+ <param index="0" name="port" type="int" />
+ <param index="1" name="max_clients" type="int" default="32" />
+ <param index="2" name="max_channels" type="int" default="0" />
+ <param index="3" name="in_bandwidth" type="int" default="0" />
+ <param index="4" name="out_bandwidth" type="int" default="0" />
<description>
Create server that listens to connections via [code]port[/code]. The port needs to be an available, unused port between 0 and 65535. Note that ports below 1024 are privileged and may require elevated permissions depending on the platform. To change the interface the server listens on, use [method set_bind_ip]. The default IP is the wildcard [code]"*"[/code], which listens on all available interfaces. [code]max_clients[/code] is the maximum number of clients that are allowed at once, any number up to 4095 may be used, although the achievable number of simultaneous clients may be far lower and depends on the application. For additional details on the bandwidth parameters, see [method create_client]. Returns [constant OK] if a server was created, [constant ERR_ALREADY_IN_USE] if this ENetMultiplayerPeer instance already has an open connection (in which case you need to call [method close_connection] first) or [constant ERR_CANT_CREATE] if the server could not be created.
</description>
</method>
<method name="get_peer" qualifiers="const">
<return type="ENetPacketPeer" />
- <argument index="0" name="id" type="int" />
+ <param index="0" name="id" type="int" />
<description>
Returns the [ENetPacketPeer] associated to the given [code]id[/code].
</description>
</method>
<method name="set_bind_ip">
<return type="void" />
- <argument index="0" name="ip" type="String" />
+ <param index="0" name="ip" type="String" />
<description>
The IP used when creating a server. This is set to the wildcard [code]"*"[/code] by default, which binds to all available interfaces. The given IP needs to be in IPv4 or IPv6 address format, for example: [code]"192.168.1.1"[/code].
</description>
diff --git a/modules/enet/doc_classes/ENetPacketPeer.xml b/modules/enet/doc_classes/ENetPacketPeer.xml
index 5de5a60853..67760ba5e8 100644
--- a/modules/enet/doc_classes/ENetPacketPeer.xml
+++ b/modules/enet/doc_classes/ENetPacketPeer.xml
@@ -18,6 +18,18 @@
Returns the number of channels allocated for communication with peer.
</description>
</method>
+ <method name="get_remote_address" qualifiers="const">
+ <return type="String" />
+ <description>
+ Returns the IP address of this peer.
+ </description>
+ </method>
+ <method name="get_remote_port" qualifiers="const">
+ <return type="int" />
+ <description>
+ Returns the remote port of this peer.
+ </description>
+ </method>
<method name="get_state" qualifiers="const">
<return type="int" enum="ENetPacketPeer.PeerState" />
<description>
@@ -26,7 +38,7 @@
</method>
<method name="get_statistic">
<return type="float" />
- <argument index="0" name="statistic" type="int" enum="ENetPacketPeer.PeerStatistic" />
+ <param index="0" name="statistic" type="int" enum="ENetPacketPeer.PeerStatistic" />
<description>
Returns the requested [code]statistic[/code] for this peer. See [enum PeerStatistic].
</description>
@@ -39,21 +51,21 @@
</method>
<method name="peer_disconnect">
<return type="void" />
- <argument index="0" name="data" type="int" default="0" />
+ <param index="0" name="data" type="int" default="0" />
<description>
Request a disconnection from a peer. An [constant ENetConnection.EVENT_DISCONNECT] will be generated during [method ENetConnection.service] once the disconnection is complete.
</description>
</method>
<method name="peer_disconnect_later">
<return type="void" />
- <argument index="0" name="data" type="int" default="0" />
+ <param index="0" name="data" type="int" default="0" />
<description>
Request a disconnection from a peer, but only after all queued outgoing packets are sent. An [constant ENetConnection.EVENT_DISCONNECT] will be generated during [method ENetConnection.service] once the disconnection is complete.
</description>
</method>
<method name="peer_disconnect_now">
<return type="void" />
- <argument index="0" name="data" type="int" default="0" />
+ <param index="0" name="data" type="int" default="0" />
<description>
Force an immediate disconnection from a peer. No [constant ENetConnection.EVENT_DISCONNECT] will be generated. The foreign peer is not guaranteed to receive the disconnect notification, and is reset immediately upon return from this function.
</description>
@@ -66,7 +78,7 @@
</method>
<method name="ping_interval">
<return type="void" />
- <argument index="0" name="ping_interval" type="int" />
+ <param index="0" name="ping_interval" type="int" />
<description>
Sets the [code]ping_interval[/code] in milliseconds at which pings will be sent to a peer. Pings are used both to monitor the liveness of the connection and also to dynamically adjust the throttle during periods of low traffic so that the throttle has reasonable responsiveness during traffic spikes.
</description>
@@ -79,18 +91,18 @@
</method>
<method name="send">
<return type="int" enum="Error" />
- <argument index="0" name="channel" type="int" />
- <argument index="1" name="packet" type="PackedByteArray" />
- <argument index="2" name="flags" type="int" />
+ <param index="0" name="channel" type="int" />
+ <param index="1" name="packet" type="PackedByteArray" />
+ <param index="2" name="flags" type="int" />
<description>
Queues a [code]packet[/code] to be sent over the specified [code]channel[/code]. See [code]FLAG_*[/code] constants for available packet flags.
</description>
</method>
<method name="set_timeout">
<return type="void" />
- <argument index="0" name="timeout" type="int" />
- <argument index="1" name="timeout_min" type="int" />
- <argument index="2" name="timeout_max" type="int" />
+ <param index="0" name="timeout" type="int" />
+ <param index="1" name="timeout_min" type="int" />
+ <param index="2" name="timeout_max" type="int" />
<description>
Sets the timeout parameters for a peer. The timeout parameters control how and when a peer will timeout from a failure to acknowledge reliable traffic. Timeout values are expressed in milliseconds.
The [code]timeout_limit[/code] is a factor that, multiplied by a value based on the average round trip time, will determine the timeout limit for a reliable packet. When that limit is reached, the timeout will be doubled, and the peer will be disconnected if that limit has reached [code]timeout_min[/code]. The [code]timeout_max[/code] parameter, on the other hand, defines a fixed timeout for which any packet must be acknowledged or the peer will be dropped.
@@ -98,9 +110,9 @@
</method>
<method name="throttle_configure">
<return type="void" />
- <argument index="0" name="interval" type="int" />
- <argument index="1" name="acceleration" type="int" />
- <argument index="2" name="deceleration" type="int" />
+ <param index="0" name="interval" type="int" />
+ <param index="1" name="acceleration" type="int" />
+ <param index="2" name="deceleration" type="int" />
<description>
Configures throttle parameter for a peer.
Unreliable packets are dropped by ENet in response to the varying conditions of the Internet connection to the peer. The throttle represents a probability that an unreliable packet should not be dropped and thus sent by ENet to the peer. By measuring fluctuations in round trip times of reliable packets over the specified [code]interval[/code], ENet will either increase the probably by the amount specified in the [code]acceleration[/code] parameter, or decrease it by the amount specified in the [code]deceleration[/code] parameter (both are ratios to [constant PACKET_THROTTLE_SCALE]).
diff --git a/modules/enet/enet_connection.cpp b/modules/enet/enet_connection.cpp
index 629974d7c7..6a4bbecf6a 100644
--- a/modules/enet/enet_connection.cpp
+++ b/modules/enet/enet_connection.cpp
@@ -34,6 +34,7 @@
#include "core/io/compression.h"
#include "core/io/ip.h"
+#include "core/variant/typed_array.h"
void ENetConnection::broadcast(enet_uint8 p_channel, ENetPacket *p_packet) {
ERR_FAIL_COND_MSG(!host, "The ENetConnection instance isn't currently active.");
@@ -263,9 +264,9 @@ void ENetConnection::get_peers(List<Ref<ENetPacketPeer>> &r_peers) {
}
}
-Array ENetConnection::_get_peers() {
+TypedArray<ENetPacketPeer> ENetConnection::_get_peers() {
ERR_FAIL_COND_V_MSG(!host, Array(), "The ENetConnection instance isn't currently active.");
- Array out;
+ TypedArray<ENetPacketPeer> out;
for (const Ref<ENetPacketPeer> &I : peers) {
out.push_back(I);
}
diff --git a/modules/enet/enet_connection.h b/modules/enet/enet_connection.h
index 0c873b6c55..5cd8f6be9a 100644
--- a/modules/enet/enet_connection.h
+++ b/modules/enet/enet_connection.h
@@ -38,6 +38,9 @@
#include <enet/enet.h>
+template <typename T>
+class TypedArray;
+
class ENetConnection : public RefCounted {
GDCLASS(ENetConnection, RefCounted);
@@ -83,7 +86,7 @@ private:
Error _create(ENetAddress *p_address, int p_max_peers, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth);
Array _service(int p_timeout = 0);
void _broadcast(int p_channel, PackedByteArray p_packet, int p_flags);
- Array _get_peers();
+ TypedArray<ENetPacketPeer> _get_peers();
class Compressor {
private:
diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp
index cd94cc9425..dfdd08c9f4 100644
--- a/modules/enet/enet_multiplayer_peer.cpp
+++ b/modules/enet/enet_multiplayer_peer.cpp
@@ -441,15 +441,15 @@ Error ENetMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size
channel = SYSCH_MAX + transfer_channel - 1;
} else {
switch (get_transfer_mode()) {
- case Multiplayer::TRANSFER_MODE_UNRELIABLE: {
+ case TRANSFER_MODE_UNRELIABLE: {
packet_flags = ENET_PACKET_FLAG_UNSEQUENCED | ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT;
channel = SYSCH_UNRELIABLE;
} break;
- case Multiplayer::TRANSFER_MODE_UNRELIABLE_ORDERED: {
+ case TRANSFER_MODE_UNRELIABLE_ORDERED: {
packet_flags = ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT;
channel = SYSCH_UNRELIABLE;
} break;
- case Multiplayer::TRANSFER_MODE_RELIABLE: {
+ case TRANSFER_MODE_RELIABLE: {
packet_flags = ENET_PACKET_FLAG_RELIABLE;
channel = SYSCH_RELIABLE;
} break;
diff --git a/modules/enet/enet_multiplayer_peer.h b/modules/enet/enet_multiplayer_peer.h
index e7b61169fb..3152068d46 100644
--- a/modules/enet/enet_multiplayer_peer.h
+++ b/modules/enet/enet_multiplayer_peer.h
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef NETWORKED_MULTIPLAYER_ENET_H
-#define NETWORKED_MULTIPLAYER_ENET_H
+#ifndef ENET_MULTIPLAYER_PEER_H
+#define ENET_MULTIPLAYER_PEER_H
#include "core/crypto/crypto.h"
-#include "core/multiplayer/multiplayer_peer.h"
+#include "scene/main/multiplayer_peer.h"
#include "enet_connection.h"
#include <enet/enet.h>
@@ -70,8 +70,8 @@ private:
ConnectionStatus connection_status = CONNECTION_DISCONNECTED;
- Map<int, Ref<ENetConnection>> hosts;
- Map<int, Ref<ENetPacketPeer>> peers;
+ HashMap<int, Ref<ENetConnection>> hosts;
+ HashMap<int, Ref<ENetPacketPeer>> peers;
struct Packet {
ENetPacket *packet = nullptr;
@@ -135,4 +135,4 @@ public:
~ENetMultiplayerPeer();
};
-#endif // NETWORKED_MULTIPLAYER_ENET_H
+#endif // ENET_MULTIPLAYER_PEER_H
diff --git a/modules/enet/enet_packet_peer.cpp b/modules/enet/enet_packet_peer.cpp
index 62c0550edb..5a96f75c4f 100644
--- a/modules/enet/enet_packet_peer.cpp
+++ b/modules/enet/enet_packet_peer.cpp
@@ -206,6 +206,8 @@ void ENetPacketPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("send", "channel", "packet", "flags"), &ENetPacketPeer::_send);
ClassDB::bind_method(D_METHOD("throttle_configure", "interval", "acceleration", "deceleration"), &ENetPacketPeer::throttle_configure);
ClassDB::bind_method(D_METHOD("set_timeout", "timeout", "timeout_min", "timeout_max"), &ENetPacketPeer::set_timeout);
+ ClassDB::bind_method(D_METHOD("get_remote_address"), &ENetPacketPeer::get_remote_address);
+ ClassDB::bind_method(D_METHOD("get_remote_port"), &ENetPacketPeer::get_remote_port);
ClassDB::bind_method(D_METHOD("get_statistic", "statistic"), &ENetPacketPeer::get_statistic);
ClassDB::bind_method(D_METHOD("get_state"), &ENetPacketPeer::get_state);
ClassDB::bind_method(D_METHOD("get_channels"), &ENetPacketPeer::get_channels);
diff --git a/modules/enet/register_types.cpp b/modules/enet/register_types.cpp
index ebc5d95348..14f3374e24 100644
--- a/modules/enet/register_types.cpp
+++ b/modules/enet/register_types.cpp
@@ -36,7 +36,11 @@
static bool enet_ok = false;
-void register_enet_types() {
+void initialize_enet_module(ModuleInitializationLevel p_level) {
+ if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
+ return;
+ }
+
if (enet_initialize() != 0) {
ERR_PRINT("ENet initialization failure");
} else {
@@ -48,7 +52,11 @@ void register_enet_types() {
GDREGISTER_CLASS(ENetConnection);
}
-void unregister_enet_types() {
+void uninitialize_enet_module(ModuleInitializationLevel p_level) {
+ if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
+ return;
+ }
+
if (enet_ok) {
enet_deinitialize();
}
diff --git a/modules/enet/register_types.h b/modules/enet/register_types.h
index a94ecccc61..b4f491287d 100644
--- a/modules/enet/register_types.h
+++ b/modules/enet/register_types.h
@@ -31,7 +31,9 @@
#ifndef ENET_REGISTER_TYPES_H
#define ENET_REGISTER_TYPES_H
-void register_enet_types();
-void unregister_enet_types();
+#include "modules/register_module_types.h"
+
+void initialize_enet_module(ModuleInitializationLevel p_level);
+void uninitialize_enet_module(ModuleInitializationLevel p_level);
#endif // ENET_REGISTER_TYPES_H