mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-25 19:41:20 -08:00
Fix packet out of order error bc of heartbeat sending packet num 0
This commit is contained in:
1 parent
51fda0ad7f
commit
bb94364830
1 file changed
+5
-8
@@ -44,17 +44,14 @@ class PacketBehaviour : UDPConnectionBehaviour {
|
||||
receiver.packetEvents.onAny { packet ->
|
||||
val state = receiver.context.state.value
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - state.lastPacket > CONNECTION_TIMEOUT_MS && packet.packetNumber == 0L) {
|
||||
receiver.context.dispatch(UDPConnectionActions.LastPacket(packetNum = 0, time = now))
|
||||
val num = packet.packetNumber
|
||||
if (num == 0L && now - state.lastPacket > CONNECTION_TIMEOUT_MS) {
|
||||
AppLogger.udp.info("[${state.address}] Reconnecting")
|
||||
} else if (packet.packetNumber != null && packet.packetNumber < state.lastPacketNum) {
|
||||
// Note: Packet number is nullable for bundled packets, as only the bundle packet itself has the number
|
||||
// the packets inside of it do not
|
||||
AppLogger.udp.warn("[${state.address}] WARN: Received packet with wrong packet number")
|
||||
} else if (num != null && num != 0L && num <= state.lastPacketNum) {
|
||||
AppLogger.udp.warn("[${state.address}] Received packet with wrong packet number")
|
||||
return@onAny
|
||||
} else {
|
||||
receiver.context.dispatch(UDPConnectionActions.LastPacket(packetNum = packet.packetNumber, time = now))
|
||||
}
|
||||
receiver.context.dispatch(UDPConnectionActions.LastPacket(packetNum = num, time = now))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user