summaryrefslogtreecommitdiff
path: root/Net1090/main.swift
diff options
context:
space:
mode:
authorArturs Artamonovs <arturs.artamonovs@protonmail.com>2024-08-08 12:25:55 +0100
committerArturs Artamonovs <arturs.artamonovs@protonmail.com>2024-08-08 12:25:55 +0100
commit30a23711626c5afe7f86ca34fbc489d7979b71d9 (patch)
tree73d131c789c9e6a06d00dfd46ef258e41d704db1 /Net1090/main.swift
parent901397ffe83cbf1aed01e6a77e00db57e9440dac (diff)
downloadADSBDecoder-30a23711626c5afe7f86ca34fbc489d7979b71d9.tar.gz
ADSBDecoder-30a23711626c5afe7f86ca34fbc489d7979b71d9.zip
Live data works
Diffstat (limited to 'Net1090/main.swift')
-rw-r--r--Net1090/main.swift36
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")