mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-04-14 11:46:26 +00:00
Wrap enet_host_service() to hide the logic required to make retransmissions work
This commit is contained in:
20
src/Misc.c
20
src/Misc.c
@@ -1,5 +1,25 @@
|
||||
#include "Limelight-internal.h"
|
||||
|
||||
#define ENET_SERVICE_RETRIES 10
|
||||
|
||||
// This function wraps enet_host_service() and hides the fact that it must be called
|
||||
// multiple times for retransmissions to work correctly. It is meant to be a drop-in
|
||||
// replacement for enet_host_service().
|
||||
int serviceEnetHost(ENetHost* client, ENetEvent* event, enet_uint32 timeoutMs) {
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
// We need to call enet_host_service() multiple times to make sure retransmissions happen
|
||||
for (i = 0; i < ENET_SERVICE_RETRIES; i++) {
|
||||
ret = enet_host_service(client, event, timeoutMs / ENET_SERVICE_RETRIES);
|
||||
if (ret != 0 || timeoutMs == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int isBeforeSignedInt(int numA, int numB, int ambiguousCase) {
|
||||
// This should be the common case for most callers
|
||||
if (numA == numB) {
|
||||
|
||||
Reference in New Issue
Block a user