Don't send keepalive too early

This commit is contained in:
Leon Böttger authored and Leon Böttger committed 2026-03-21 21:16:26 +01:00
1 parent 04e056da02
commit 429069f372
2 files changed
+2 -5

No files matched your search

@@ -657,7 +657,7 @@ class NearbyConnection {
return
}
if lastKeepAliveFrameSent.isOlderThan(seconds: ackInterval) {
if encryptionDone && lastKeepAliveFrameSent.isOlderThan(seconds: ackInterval) {
sendKeepAlive(ack: false)
}
@@ -307,10 +307,7 @@ class OutboundNearbyConnection: NearbyConnection {
guard frame.hasV1, frame.v1.hasType else { throw NearbyError.requiredFieldMissing("offlineFrame.v1.type") }
if frame.v1.type == .keepAlive {
log("[OutboundNearbyConnection \(self.id)] Received keep-alive while waiting for connection response")
if frame.v1.hasKeepAlive, !frame.v1.keepAlive.ack {
sendKeepAlive(ack: true)
}
log("[OutboundNearbyConnection \(self.id)] Ignoring keep-alive while waiting for connection response")
return
}