summaryrefslogtreecommitdiff
path: root/thirdparty/enet/godot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/enet/godot.cpp')
-rw-r--r--thirdparty/enet/godot.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp
index 9fefa53e77..36b5131f80 100644
--- a/thirdparty/enet/godot.cpp
+++ b/thirdparty/enet/godot.cpp
@@ -51,6 +51,7 @@ public:
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) = 0;
virtual int set_option(ENetSocketOption p_option, int p_value) = 0;
virtual void close() = 0;
+ virtual void set_refuse_new_connections(bool p_refuse) { /* Only used by dtls server */ }
virtual ~ENetGodotSocket(){};
};
@@ -250,6 +251,10 @@ public:
close();
}
+ void set_refuse_new_connections(bool p_refuse) {
+ udp_server->set_max_pending_connections(p_refuse ? 0 : 16);
+ }
+
Error bind(IP_Address p_ip, uint16_t p_port) {
return udp_server->listen(p_port, p_ip);
}
@@ -269,6 +274,7 @@ public:
}
Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) {
+ udp_server->poll();
// TODO limits? Maybe we can better enforce allowed connections!
if (udp_server->is_connection_available()) {
Ref<PacketPeerUDP> udp = udp_server->take_connection();
@@ -409,6 +415,11 @@ void enet_host_dtls_client_setup(ENetHost *host, void *p_cert, uint8_t p_verify,
memdelete(sock);
}
+void enet_host_refuse_new_connections(ENetHost *host, int p_refuse) {
+ ERR_FAIL_COND(!host->socket);
+ ((ENetGodotSocket *)host->socket)->set_refuse_new_connections(p_refuse);
+}
+
int enet_socket_bind(ENetSocket socket, const ENetAddress *address) {
IP_Address ip;