diff options
Diffstat (limited to 'Net1090/main.swift')
-rw-r--r-- | Net1090/main.swift | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/Net1090/main.swift b/Net1090/main.swift index d142613..06c2652 100644 --- a/Net1090/main.swift +++ b/Net1090/main.swift @@ -10,16 +10,36 @@ import Network import NIO - +var timer: Timer? +let ADSBClient = NetADSBDecoder(host: "192.168.4.201", port: 30002) print("Hello, World!") -print("Start listening client") +print("Start listening client 2") -let ADSBClient = NetADSBDecoder(host: "192.168.4.201", port: 30002) -do { - try ADSBClient.start() -} catch let error { - print("Error: \(error.localizedDescription)") - ADSBClient.stop() +//var timer:Timer? +timer = Timer.scheduledTimer( + withTimeInterval: 1, + repeats: true +) { _ in + print("Timer drain queue") + print("\(ADSBClient.msgarray.message_array.count)") + if ADSBClient.msgarray.message_array.count > 0 { + print(ADSBClient.msgarray.message_array.count) + for i in 0..<ADSBClient.msgarray.message_array.count { + print("adsb-message:\(ADSBClient.msgarray.message_array.popLast()!)") + } + } } +print("start") + +DispatchQueue.global(qos: .background).async { + do { + try ADSBClient.start() + } catch let error { + print("Error: \(error.localizedDescription)") + ADSBClient.stop() + } +} +RunLoop.current.run() +print("end") |