diff --git a/modules/enet/doc_classes/ENetConnection.xml b/modules/enet/doc_classes/ENetConnection.xml index 940d3be75883..790d8df622e5 100644 --- a/modules/enet/doc_classes/ENetConnection.xml +++ b/modules/enet/doc_classes/ENetConnection.xml @@ -118,6 +118,12 @@ Returns the maximum number of channels allowed for connected peers. + + + + Returns the maximum number of peers that can be connected at once. + + diff --git a/modules/enet/enet_connection.cpp b/modules/enet/enet_connection.cpp index 9b764b1ad9a2..2f86057e2a08 100644 --- a/modules/enet/enet_connection.cpp +++ b/modules/enet/enet_connection.cpp @@ -245,6 +245,11 @@ double ENetConnection::pop_statistic(HostStatistic p_stat) { return ret; } +int ENetConnection::get_max_peers() const { + ERR_FAIL_NULL_V_MSG(host, 0, "The ENetConnection instance isn't currently active."); + return host->peerCount; +} + int ENetConnection::get_max_channels() const { ERR_FAIL_NULL_V_MSG(host, 0, "The ENetConnection instance isn't currently active."); return host->channelLimit; @@ -386,6 +391,7 @@ void ENetConnection::_bind_methods() { ClassDB::bind_method(D_METHOD("dtls_client_setup", "hostname", "client_options"), &ENetConnection::dtls_client_setup, DEFVAL(Ref())); ClassDB::bind_method(D_METHOD("refuse_new_connections", "refuse"), &ENetConnection::refuse_new_connections); ClassDB::bind_method(D_METHOD("pop_statistic", "statistic"), &ENetConnection::pop_statistic); + ClassDB::bind_method(D_METHOD("get_max_peers"), &ENetConnection::get_max_peers); ClassDB::bind_method(D_METHOD("get_max_channels"), &ENetConnection::get_max_channels); ClassDB::bind_method(D_METHOD("get_local_port"), &ENetConnection::get_local_port); ClassDB::bind_method(D_METHOD("get_peers"), &ENetConnection::_get_peers); diff --git a/modules/enet/enet_connection.h b/modules/enet/enet_connection.h index 3375d11b4934..3664ea4f3d62 100644 --- a/modules/enet/enet_connection.h +++ b/modules/enet/enet_connection.h @@ -121,6 +121,7 @@ class ENetConnection : public RefCounted { void bandwidth_throttle(); void compress(CompressionMode p_mode); double pop_statistic(HostStatistic p_stat); + int get_max_peers() const; int get_max_channels() const; // Extras