Add fail check for deserialization error

This commit is contained in:
Leon Böttger committed 2025-05-03 15:08:45 +02:00
1 parent a810a59b20
commit 99c57e9927
1 file changed
+14 -1
+14 -1
View File
@@ -71,7 +71,20 @@ class InboundNearbyConnection: NearbyConnection{
}catch{
lastError = error
log("Deserialization error: \(error) in state \(currentState). Payload: \(frameData.hex)")
//protocolError()
let lastState = currentState
log("Waiting for 5 seconds to check if connection is still alive")
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
if self.currentState == lastState {
log("Still in state \(self.currentState), last state was \(lastState)")
self.protocolError()
}
else {
log("State changed to \(self.currentState), not closing connection")
}
}
}
}