Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/enet/doc_classes/ENetConnection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@
Returns the maximum number of channels allowed for connected peers.
</description>
</method>
<method name="get_max_peers" qualifiers="const">
<return type="int" />
<description>
Returns the maximum number of peers that can be connected at once.
</description>
</method>
<method name="get_peers">
<return type="ENetPacketPeer[]" />
<description>
Expand Down
6 changes: 6 additions & 0 deletions modules/enet/enet_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<TLSOptions>()));
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);
Expand Down
1 change: 1 addition & 0 deletions modules/enet/enet_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down