Wrap enet_host_service() to hide the logic required to make retransmissions work

This commit is contained in:
Cameron Gutman
2016-04-18 16:27:50 -04:00
parent 33deb0fe1a
commit d5e0950ec6
4 changed files with 29 additions and 6 deletions

View File

@@ -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) {