Better tracker timeout handling

This commit is contained in:
Eiren Rain committed 2022-02-15 09:59:27 +02:00
1 parent bfc58d51f2
commit e7b9968519
2 files changed
+7 -1

No files matched your search

@@ -23,6 +23,7 @@ public class TrackerUDPConnection {
public long lastPacketNumber = -1;
public NetworkProtocol protocol = null;
public int firmwareBuild = 0;
public boolean timedOut = false;
public TrackerUDPConnection(SocketAddress address, InetAddress ipAddress) {
this.address = address;
@@ -204,7 +204,7 @@ public class TrackersUDPServer extends Thread {
}
} catch(SocketTimeoutException e) {
} catch(Exception e) {
LogManager.log.warning("Error parsing packet " + packetToString(received), e);
LogManager.log.warning("[TrackerServer] Error parsing packet " + packetToString(received), e);
}
if(lastKeepup + 500 < System.currentTimeMillis()) {
lastKeepup = System.currentTimeMillis();
@@ -222,7 +222,12 @@ public class TrackersUDPServer extends Thread {
if(tracker.getStatus() == TrackerStatus.OK)
tracker.setStatus(TrackerStatus.DISCONNECTED);
}
if(!conn.timedOut) {
conn.timedOut = true;
LogManager.log.info("[TrackerServer] Tracker timed out: " + conn);
}
} else {
conn.timedOut = false;
Iterator<IMUTracker> iterator = conn.sensors.values().iterator();
while(iterator.hasNext()) {
IMUTracker tracker = iterator.next();