summaryrefslogtreecommitdiff
path: root/Net1090/main.swift
blob: 06c2652e6544cc68f7e9c98b203df07e311b8861 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
//  main.swift
//  Net1090
//
//  Created by Jacky Jack on 11/07/2024.
//

import Foundation
import Network
import NIO


var timer: Timer?
let ADSBClient = NetADSBDecoder(host: "192.168.4.201", port: 30002)

print("Hello, World!")
print("Start listening client 2")

//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")