| 59 | } |
| 60 | |
| 61 | void NetworkConnection::receivePacket(const Packet& packet) |
| 62 | { |
| 63 | _timeOfLastReceivedPacket = Platform::getTime(); |
| 64 | |
| 65 | logPacket(packet, false, false); |
| 66 | if (packet.header.kind == PacketKind::ack) |
| 67 | { |
| 68 | receiveAcknowledgePacket(packet.header.sequence); |
| 69 | } |
| 70 | else |
| 71 | { |
| 72 | // Send ACK back, even if we have already received this packet before |
| 73 | // the ACK we sent before, may not have been delivered successfully |
| 74 | sendAcknowledgePacket(packet.header.sequence); |
| 75 | |
| 76 | // Only store the packet, if this is the first time we received it |
| 77 | if (!checkOrRecordReceivedSequence(packet.header.sequence)) |
| 78 | { |
| 79 | std::unique_lock<std::mutex> lk(_receivedPacketsSync); |
| 80 | _receivedPackets.push(packet); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | void NetworkConnection::sendPacket(PacketKind kind, size_t dataSize, const void* packetData) |
| 86 | { |
no test coverage detected