mirror of
https://github.com/lsalzman/enet
synced 2024-11-21 06:25:59 -07:00
minimum and maximum timeout
This commit is contained in:
parent
2ef761a8d2
commit
59d5c26e38
3 changed files with 14 additions and 2 deletions
|
@ -167,8 +167,10 @@ enum
|
|||
ENET_PEER_PACKET_LOSS_INTERVAL = 10000,
|
||||
ENET_PEER_WINDOW_SIZE_SCALE = 64 * 1024,
|
||||
ENET_PEER_TIMEOUT_LIMIT = 32,
|
||||
ENET_PEER_TIMEOUT_MINIMUM = 3000,
|
||||
ENET_PEER_TIMEOUT_MAXIMUM = 30000,
|
||||
ENET_PEER_PING_INTERVAL = 500,
|
||||
ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 4 * 32
|
||||
ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 4 * 32,
|
||||
};
|
||||
|
||||
typedef struct _ENetChannel
|
||||
|
@ -206,6 +208,7 @@ typedef struct _ENetPeer
|
|||
enet_uint32 lastSendTime;
|
||||
enet_uint32 lastReceiveTime;
|
||||
enet_uint32 nextTimeout;
|
||||
enet_uint32 earliestTimeout;
|
||||
enet_uint32 packetLossEpoch;
|
||||
enet_uint32 packetsSent;
|
||||
enet_uint32 packetsLost;
|
||||
|
|
1
peer.c
1
peer.c
|
@ -351,6 +351,7 @@ enet_peer_reset (ENetPeer * peer)
|
|||
peer -> lastSendTime = 0;
|
||||
peer -> lastReceiveTime = 0;
|
||||
peer -> nextTimeout = 0;
|
||||
peer -> earliestTimeout = 0;
|
||||
peer -> packetLossEpoch = 0;
|
||||
peer -> packetsSent = 0;
|
||||
peer -> packetsLost = 0;
|
||||
|
|
10
protocol.c
10
protocol.c
|
@ -486,6 +486,7 @@ enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer *
|
|||
return 0;
|
||||
|
||||
peer -> lastReceiveTime = timeCurrent;
|
||||
peer -> earliestTimeout = 0;
|
||||
|
||||
roundTripTime = ENET_TIME_DIFFERENCE (timeCurrent, receivedSentTime);
|
||||
|
||||
|
@ -948,7 +949,14 @@ enet_protocol_check_timeouts (ENetHost * host, ENetPeer * peer, ENetEvent * even
|
|||
if (ENET_TIME_DIFFERENCE (timeCurrent, outgoingCommand -> sentTime) < outgoingCommand -> roundTripTimeout)
|
||||
continue;
|
||||
|
||||
if (outgoingCommand -> roundTripTimeout >= outgoingCommand -> roundTripTimeoutLimit)
|
||||
if(peer -> earliestTimeout == 0 ||
|
||||
ENET_TIME_LESS(outgoingCommand -> sentTime, peer -> earliestTimeout))
|
||||
peer -> earliestTimeout = outgoingCommand -> sentTime;
|
||||
|
||||
if (peer -> earliestTimeout != 0 &&
|
||||
(ENET_TIME_DIFFERENCE(timeCurrent, peer -> earliestTimeout) >= ENET_PEER_TIMEOUT_MAXIMUM ||
|
||||
(outgoingCommand -> roundTripTimeout >= outgoingCommand -> roundTripTimeoutLimit &&
|
||||
ENET_TIME_DIFFERENCE(timeCurrent, peer -> earliestTimeout) >= ENET_PEER_TIMEOUT_MINIMUM)))
|
||||
{
|
||||
event -> type = ENET_EVENT_TYPE_DISCONNECT;
|
||||
event -> peer = peer;
|
||||
|
|
Loading…
Reference in a new issue