fix
This commit is contained in:
parent
9a76b61ff0
commit
3ce4e05613
@ -134,9 +134,7 @@ public class SDLContext: @unchecked Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
try await group.waitForAll()
|
||||
}
|
||||
|
||||
group.addTask {
|
||||
// 启动网络监控
|
||||
self.monitorCancel = self.monitor.eventFlow.sink { event in
|
||||
switch event {
|
||||
@ -153,6 +151,10 @@ public class SDLContext: @unchecked Sendable {
|
||||
self.monitor.start()
|
||||
}
|
||||
|
||||
try await group.waitForAll()
|
||||
}
|
||||
}
|
||||
|
||||
public func stop() async {
|
||||
self.superClient = nil
|
||||
self.udpHole = nil
|
||||
@ -376,18 +378,18 @@ public class SDLContext: @unchecked Sendable {
|
||||
}
|
||||
|
||||
// 流量统计
|
||||
public func flowReportTask() {
|
||||
Task {
|
||||
// 每分钟汇报一次
|
||||
self.flowTracerCancel = Timer.publish(every: 60.0, on: .main, in: .common).autoconnect()
|
||||
.sink { _ in
|
||||
Task {
|
||||
let (forwardNum, p2pNum, inboundNum) = await self.flowTracer.reset()
|
||||
await self.superClient?.flowReport(forwardNum: forwardNum, p2pNum: p2pNum, inboundNum: inboundNum)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// public func flowReportTask() {
|
||||
// Task {
|
||||
// // 每分钟汇报一次
|
||||
// self.flowTracerCancel = Timer.publish(every: 60.0, on: .main, in: .common).autoconnect()
|
||||
// .sink { _ in
|
||||
// Task {
|
||||
// let (forwardNum, p2pNum, inboundNum) = await self.flowTracer.reset()
|
||||
// await self.superClient?.flowReport(forwardNum: forwardNum, p2pNum: p2pNum, inboundNum: inboundNum)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// 网络改变时需要重新配置网络信息
|
||||
private func didNetworkConfigChanged(devAddr: SDLDevAddr, dnsServers: [String]? = nil) async {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user