This commit is contained in:
anlicheng 2025-08-01 12:19:32 +08:00
parent 9a76b61ff0
commit 3ce4e05613

View File

@ -134,9 +134,7 @@ public class SDLContext: @unchecked Sendable {
} }
} }
try await group.waitForAll() group.addTask {
}
// //
self.monitorCancel = self.monitor.eventFlow.sink { event in self.monitorCancel = self.monitor.eventFlow.sink { event in
switch event { switch event {
@ -153,6 +151,10 @@ public class SDLContext: @unchecked Sendable {
self.monitor.start() self.monitor.start()
} }
try await group.waitForAll()
}
}
public func stop() async { public func stop() async {
self.superClient = nil self.superClient = nil
self.udpHole = nil self.udpHole = nil
@ -376,18 +378,18 @@ public class SDLContext: @unchecked Sendable {
} }
// //
public func flowReportTask() { // public func flowReportTask() {
Task { // Task {
// // //
self.flowTracerCancel = Timer.publish(every: 60.0, on: .main, in: .common).autoconnect() // self.flowTracerCancel = Timer.publish(every: 60.0, on: .main, in: .common).autoconnect()
.sink { _ in // .sink { _ in
Task { // Task {
let (forwardNum, p2pNum, inboundNum) = await self.flowTracer.reset() // let (forwardNum, p2pNum, inboundNum) = await self.flowTracer.reset()
await self.superClient?.flowReport(forwardNum: forwardNum, p2pNum: p2pNum, inboundNum: inboundNum) // await self.superClient?.flowReport(forwardNum: forwardNum, p2pNum: p2pNum, inboundNum: inboundNum)
} // }
} // }
} // }
} // }
// //
private func didNetworkConfigChanged(devAddr: SDLDevAddr, dnsServers: [String]? = nil) async { private func didNetworkConfigChanged(devAddr: SDLDevAddr, dnsServers: [String]? = nil) async {