Skip to content

Commit

Permalink
Fix some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nab138 committed May 7, 2024
1 parent 83f28bf commit 799e2b9
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/NetworkTables/NT4Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ class NT4Client: WebSocketDelegate {

case .binary(let data):
do {
let decodedObj: [Any]? = try data.unpack()
if decodedObj == nil {
NSLog("Failed to unpack data")
return
}
let decodedObj: [Any]? = try data.unpack() as? [Any]
guard let decodedObj = decodedObj else { return }
handleMsgPackMessage(msg: decodedObj)
} catch {
NSLog("Something went wrong while unpacking data: \(error)")
Expand Down Expand Up @@ -122,8 +119,8 @@ class NT4Client: WebSocketDelegate {
switch method {
case "announce":
let newTopic = NTTopic(data: params)
serverTopics[topic.name] = newTopic
onTopicAnnounce(newTopic)
serverTopics[newTopic.name] = newTopic
onTopicAnnounce?(newTopic)
NSLog("Announce: \(params)")
default:
NSLog("Unknown method: \(method)")
Expand All @@ -134,7 +131,7 @@ class NT4Client: WebSocketDelegate {

private func handleMsgPackMessage(msg: [Any]){
let topicID = msg[0] as! Int
let timestamp = msg[1] as! Int
let timestamp = msg[1] as! Int64
let data = msg[2]

if topicID >= 0 {
Expand All @@ -151,7 +148,7 @@ class NT4Client: WebSocketDelegate {
onNewTopicData?(topic, timestamp, data)
} else if topicID == -1 {
// Handle receive timestamp
wsHandleReceiveTimestamp(timestamp, Int64(data as! Int))
wsHandleReceiveTimestamp(serverTimestamp: timestamp, clientTimestamp: Int64(data as! Int))
}
}

Expand Down

0 comments on commit 799e2b9

Please sign in to comment.