Roughed out ReliablePacketController#sentAck

This commit is contained in:
Collin Smith 2020-06-23 20:41:32 -07:00
parent c268d69ff9
commit 185bd6a73d
2 changed files with 17 additions and 0 deletions

View File

@ -117,5 +117,8 @@ public class ReliableEndpoint implements MessageChannel.PacketTransceiver {
public int NUM_FRAGMENTS_SENT;
public int NUM_FRAGMENTS_RECEIVED;
public int NUM_FRAGMENTS_INVALID;
public int NUM_ACKS_SENT;
public int NUM_ACKS_RECEIVED;
public int NUM_ACKS_INVALID;
}
}

View File

@ -51,7 +51,21 @@ public class ReliablePacketController {
}
public void sendAck(int channelId, DatagramChannel ch) {
int ack, ackBits;
synchronized (receivedPackets) {
ack = receivedPackets.generateAck();
ackBits = receivedPackets.generateAckBits(ack);
}
ByteBuf packet = ch.alloc().directBuffer(config.packetHeaderSize);
int headerSize = Packet.writeAck(packet, channelId, ack, ackBits);
if (headerSize < 0) {
Log.error(TAG, "failed to write ack");
ReliableEndpoint.stats.NUM_ACKS_INVALID++;
return;
}
ch.writeAndFlush(packet);
}
public int sendPacket(int channelId, DatagramChannel ch, ByteBuf bb) {