summaryrefslogtreecommitdiffstats
path: root/modules/enet/enet_connection.h
diff options
context:
space:
mode:
authorJordan Schidlowsky <jordan@winterpixel.com>2021-09-27 11:07:00 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-12-15 14:03:42 +0100
commit373d5ea103afff9707ada7a228fd34a4ddf279f5 (patch)
treeb4d0256469880aa3b83b84bcc8bb14916fbd3295 /modules/enet/enet_connection.h
parent397d895fb76d37881933c6e42b6256847ef6f2e6 (diff)
downloadredot-engine-373d5ea103afff9707ada7a228fd34a4ddf279f5.tar.gz
[Net] ENet poll now only service the connection once.
It used to call `enet_host_service` until all events were consumed, but that also meant constantly polling the connection leading to potentially unbounded processing time. It now only service the connection once, and instead consumes all the retrieved events via `enet_host_check_events`.
Diffstat (limited to 'modules/enet/enet_connection.h')
-rw-r--r--modules/enet/enet_connection.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/modules/enet/enet_connection.h b/modules/enet/enet_connection.h
index 0f7744953e..bffda81906 100644
--- a/modules/enet/enet_connection.h
+++ b/modules/enet/enet_connection.h
@@ -79,6 +79,7 @@ private:
ENetHost *host = nullptr;
List<Ref<ENetPacketPeer>> peers;
+ EventType _parse_event(const ENetEvent &p_event, Event &r_event);
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);
@@ -110,6 +111,7 @@ public:
void destroy();
Ref<ENetPacketPeer> connect_to_host(const String &p_address, int p_port, int p_channels, int p_data = 0);
EventType service(int p_timeout, Event &r_event);
+ int check_events(EventType &r_type, Event &r_event);
void flush();
void bandwidth_limit(int p_in_bandwidth = 0, int p_out_bandwidth = 0);
void channel_limit(int p_max_channels);