Skip to content
Snippets Groups Projects
Commit ff2bca68 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Handle missing round results in MessageDeliveryCallback

parent 9d87117c
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!48Handle missing round results in MessageDeliveryCallback
......@@ -30,12 +30,15 @@ extension MessageDeliveryCallback {
let callback: MessageDeliveryCallback
func eventCallback(_ delivered: Bool, timedOut: Bool, roundResults: Data?) {
if delivered,
!timedOut,
let roundResultsData = roundResults,
let roundResults = try? JSONDecoder().decode([Int].self, from: roundResultsData)
{
callback.handle(.delivered(roundResults: roundResults))
if delivered && !timedOut {
let roundResultsArray: [Int]
if let data = roundResults,
let array = try? JSONDecoder().decode([Int].self, from: data) {
roundResultsArray = array
} else {
roundResultsArray = []
}
callback.handle(.delivered(roundResults: roundResultsArray))
return
}
......@@ -48,7 +51,7 @@ extension MessageDeliveryCallback {
BindingsMessageDeliveryCallback received invalid parameters:
- delivered → \(delivered)
- timedOut → \(timedOut)
- roundResults → \(roundResults.map { String(data: $0, encoding: .utf8) ?? "" } ?? "")
- roundResults → \(roundResults.map { String(data: $0, encoding: .utf8) ?? "\($0)" } ?? "nil")
""")
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment