fix pingRemote

This commit is contained in:
Jürg Schulthess 2024-07-10 20:23:29 +02:00
parent 706dc03b3e
commit 1d9347ed23

View File

@ -230,14 +230,21 @@ public class RNSPeer {
/** Utility methods */
public void pingRemote() {
var link = this.peerLink;
log.info("pinging remote: {}", link);
var data = "ping".getBytes(UTF_8);
link.setPacketCallback(this::linkPacketReceived);
Packet pingPacket = new Packet(link, data);
PacketReceipt packetReceipt = pingPacket.send();
//packetReceipt.setTimeout(3L);
packetReceipt.setTimeoutCallback(this::packetTimedOut);
packetReceipt.setDeliveryCallback(this::packetDelivered);
if (nonNull(link)) {
if (peerLink.getStatus() == ACTIVE) {
log.info("pinging remote: {}", link);
var data = "ping".getBytes(UTF_8);
link.setPacketCallback(this::linkPacketReceived);
Packet pingPacket = new Packet(link, data);
PacketReceipt packetReceipt = pingPacket.send();
//packetReceipt.setTimeout(3L);
packetReceipt.setTimeoutCallback(this::packetTimedOut);
packetReceipt.setDeliveryCallback(this::packetDelivered);
} else {
log.info("can't send ping to a peer {} with (link) status: {}",
Hex.encodeHexString(peerLink.getDestination().getHash()), peerLink.getStatus());
}
}
}
//public void shutdownLink(Link link) {