added per-peer configurable ping interval and timeouts
1.3.4 release prep
This commit is contained in:
@@ -372,6 +372,10 @@ enet_peer_reset (ENetPeer * peer)
|
||||
peer -> packetThrottleAcceleration = ENET_PEER_PACKET_THROTTLE_ACCELERATION;
|
||||
peer -> packetThrottleDeceleration = ENET_PEER_PACKET_THROTTLE_DECELERATION;
|
||||
peer -> packetThrottleInterval = ENET_PEER_PACKET_THROTTLE_INTERVAL;
|
||||
peer -> pingInterval = ENET_PEER_PING_INTERVAL;
|
||||
peer -> timeoutLimit = ENET_PEER_TIMEOUT_LIMIT;
|
||||
peer -> timeoutMinimum = ENET_PEER_TIMEOUT_MINIMUM;
|
||||
peer -> timeoutMaximum = ENET_PEER_TIMEOUT_MAXIMUM;
|
||||
peer -> lastRoundTripTime = ENET_PEER_DEFAULT_ROUND_TRIP_TIME;
|
||||
peer -> lowestRoundTripTime = ENET_PEER_DEFAULT_ROUND_TRIP_TIME;
|
||||
peer -> lastRoundTripTimeVariance = 0;
|
||||
@@ -412,6 +416,46 @@ enet_peer_ping (ENetPeer * peer)
|
||||
enet_peer_queue_outgoing_command (peer, & command, NULL, 0, 0);
|
||||
}
|
||||
|
||||
/** Sets the interval at which pings will be sent to a peer.
|
||||
|
||||
Pings are used both to monitor the liveness of the connection and also to dynamically
|
||||
adjust the throttle during periods of low traffic so that the throttle has reasonable
|
||||
responsiveness during traffic spikes.
|
||||
|
||||
@param peer the peer to adjust
|
||||
@param pingInterval the interval at which to send pings; defaults to ENET_PEER_PING_INTERVAL if 0
|
||||
*/
|
||||
void
|
||||
enet_peer_ping_interval (ENetPeer * peer, enet_uint32 pingInterval)
|
||||
{
|
||||
peer -> pingInterval = pingInterval ? pingInterval : ENET_PEER_PING_INTERVAL;
|
||||
}
|
||||
|
||||
/** Sets the timeout parameters for a peer.
|
||||
|
||||
The timeout parameter control how and when a peer will timeout from a failure to acknowledge
|
||||
reliable traffic. Timeout values use an exponential backoff mechanism, where if a reliable
|
||||
packet is not acknowledge within some multiple of the average RTT plus a variance tolerance,
|
||||
the timeout will be doubled until it reaches a set limit. If the timeout is thus at this
|
||||
limit and reliable packets have been sent but not acknowledged within a certain minimum time
|
||||
period, the peer will be disconnected. Alternatively, if reliable packets have been sent
|
||||
but not acknowledged for a certain maximum time period, the peer will be disconnected regardless
|
||||
of the current timeout limit value.
|
||||
|
||||
@param peer the peer to adjust
|
||||
@param timeoutLimit the timeout limit; defaults to ENET_PEER_TIMEOUT_LIMIT if 0
|
||||
@param timeoutMinimum the timeout minimum; defaults to ENET_PEER_TIMEOUT_MINIMUM if 0
|
||||
@param timeoutMaximum the timeout maximum; defaults to ENET_PEER_TIMEOUT_MAXIMUM if 0
|
||||
*/
|
||||
|
||||
void
|
||||
enet_peer_timeout (ENetPeer * peer, enet_uint32 timeoutLimit, enet_uint32 timeoutMinimum, enet_uint32 timeoutMaximum)
|
||||
{
|
||||
peer -> timeoutLimit = timeoutLimit ? timeoutLimit : ENET_PEER_TIMEOUT_LIMIT;
|
||||
peer -> timeoutMinimum = timeoutMinimum ? timeoutMinimum : ENET_PEER_TIMEOUT_MINIMUM;
|
||||
peer -> timeoutMaximum = timeoutMaximum ? timeoutMaximum : ENET_PEER_TIMEOUT_MAXIMUM;
|
||||
}
|
||||
|
||||
/** Force an immediate disconnection from a peer.
|
||||
@param peer peer to disconnect
|
||||
@param data data describing the disconnection
|
||||
|
||||
Reference in New Issue
Block a user