diff options
Diffstat (limited to 'modules/enet')
-rw-r--r-- | modules/enet/doc_classes/ENetConnection.xml | 2 | ||||
-rw-r--r-- | modules/enet/doc_classes/ENetPacketPeer.xml | 12 | ||||
-rw-r--r-- | modules/enet/enet_connection.cpp | 5 | ||||
-rw-r--r-- | modules/enet/enet_connection.h | 5 | ||||
-rw-r--r-- | modules/enet/enet_packet_peer.cpp | 2 |
5 files changed, 22 insertions, 4 deletions
diff --git a/modules/enet/doc_classes/ENetConnection.xml b/modules/enet/doc_classes/ENetConnection.xml index c9bf1c65e1..8c84fe87d7 100644 --- a/modules/enet/doc_classes/ENetConnection.xml +++ b/modules/enet/doc_classes/ENetConnection.xml @@ -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. diff --git a/modules/enet/doc_classes/ENetPacketPeer.xml b/modules/enet/doc_classes/ENetPacketPeer.xml index 46008317a2..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> 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_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); |