diff options
author | Lee Salzman <[email protected]> | 2014-04-14 19:11:44 +0300 |
---|---|---|
committer | Lee Salzman <[email protected]> | 2014-04-14 19:11:44 +0300 |
commit | ea8d41f65c559bf2b74c59538e340ea0023d60fe (patch) | |
tree | aa1e720531ef71e2bdc550152411b465113f9b2c /peer.c | |
parent | 73c930881f7acabc9bea99eb698d0824cbe22c3e (diff) | |
download | enet-ea8d41f65c559bf2b74c59538e340ea0023d60fe.tar.gz enet-ea8d41f65c559bf2b74c59538e340ea0023d60fe.zip |
added maximumPacketSize and maximumWaitingData fields for limiting peer buffer space
Diffstat (limited to 'peer.c')
-rw-r--r-- | peer.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -105,7 +105,7 @@ enet_peer_send (ENetPeer * peer, enet_uint8 channelID, ENetPacket * packet) if (peer -> state != ENET_PEER_STATE_CONNECTED || channelID >= peer -> channelCount || - packet -> dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE) + packet -> dataLength > peer -> host -> maximumPacketSize) return -1; fragmentLength = peer -> mtu - sizeof (ENetProtocolHeader) - sizeof (ENetProtocolSendFragment); @@ -241,6 +241,8 @@ enet_peer_receive (ENetPeer * peer, enet_uint8 * channelID) enet_free (incomingCommand); + peer -> totalWaitingData -= packet -> dataLength; + return packet; } @@ -415,6 +417,7 @@ enet_peer_reset (ENetPeer * peer) peer -> incomingUnsequencedGroup = 0; peer -> outgoingUnsequencedGroup = 0; peer -> eventData = 0; + peer -> totalWaitingData = 0; memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow)); @@ -952,7 +955,11 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, } if (packet != NULL) - ++ packet -> referenceCount; + { + ++ packet -> referenceCount; + + peer -> totalWaitingData += packet -> dataLength; + } enet_list_insert (enet_list_next (currentCommand), incomingCommand); |