use of i2p.bote.packet.CommunicationPacket in project i2p.i2p-bote by i2p.
the class I2PSendQueue method send.
/**
* This method actually sends a packet via the router
*/
private void send(ScheduledPacket scheduledPacket) throws InterruptedException {
CommunicationPacket i2pBotePacket = scheduledPacket.data;
byte[] bytes = i2pBotePacket.toByteArray();
PacketBatch batch = scheduledPacket.batch;
boolean isBatchPacket = batch != null;
log.debug("Sending " + (isBatchPacket ? "" : "non-") + "batch packet: [" + i2pBotePacket + "] to " + Util.toShortenedBase32(scheduledPacket.destination));
try {
sendDatagram(bytes, scheduledPacket.destination);
// set sentTime, update queue and sentLatch, fire packet listeners
scheduledPacket.data.setSentTime(System.currentTimeMillis());
if (isBatchPacket)
batch.decrementSentLatch();
scheduledPacket.decrementSentLatch();
} catch (Exception exc) {
log.error("Can't send packet.", exc);
// pause to avoid CPU hogging if the error doesn't go away
TimeUnit.SECONDS.sleep(1);
}
}
Aggregations