mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-19 16:57:20 +07:00
Roughed out ReliablePacketController#sentAck
This commit is contained in:
parent
c268d69ff9
commit
185bd6a73d
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user