fix
This commit is contained in:
parent
d1452ce0b7
commit
1f629a58a0
@ -47,8 +47,8 @@ public class SDLContext: @unchecked Sendable {
|
||||
let rsaCipher: RSACipher
|
||||
|
||||
// 依赖的变量
|
||||
var udpHoleActor: SDLUDPHoleActor?
|
||||
var superClientActor: SDLSuperClientActor?
|
||||
var udpHoleActor: SDLUDPHole?
|
||||
var superClientActor: SDLSuperClient?
|
||||
|
||||
// 数据包读取任务
|
||||
private var readTask: Task<(), Never>?
|
||||
@ -93,8 +93,8 @@ public class SDLContext: @unchecked Sendable {
|
||||
}
|
||||
|
||||
public func start() async throws {
|
||||
self.udpHoleActor = try await SDLUDPHoleActor()
|
||||
self.superClientActor = try await SDLSuperClientActor(host: self.config.superHost, port: self.config.superPort)
|
||||
self.udpHoleActor = try await SDLUDPHole()
|
||||
self.superClientActor = try await SDLSuperClient(host: self.config.superHost, port: self.config.superPort)
|
||||
self.noticeClient = try await SDLNoticeClient()
|
||||
|
||||
try await withThrowingTaskGroup(of: Void.self) { group in
|
||||
@ -160,7 +160,7 @@ public class SDLContext: @unchecked Sendable {
|
||||
self.readTask?.cancel()
|
||||
}
|
||||
|
||||
private func handleSuperEvent(event: SDLSuperClientActor.SuperEvent) async throws {
|
||||
private func handleSuperEvent(event: SDLSuperClient.SuperEvent) async throws {
|
||||
switch event {
|
||||
case .ready:
|
||||
NSLog("[SDLContext] get registerSuper, mac address: \(Self.formatMacAddress(mac: self.devAddr.mac))")
|
||||
@ -273,7 +273,7 @@ public class SDLContext: @unchecked Sendable {
|
||||
// try await self.udpHole?.start()
|
||||
}
|
||||
|
||||
private func handleUDPEvent(event: SDLUDPHoleActor.UDPEvent) async throws {
|
||||
private func handleUDPEvent(event: SDLUDPHole.UDPEvent) async throws {
|
||||
switch event {
|
||||
case .ready:
|
||||
// 获取当前网络的类型
|
||||
|
||||
@ -22,7 +22,7 @@ struct SDLNatProber {
|
||||
}
|
||||
|
||||
// 获取当前所处的网络的nat类型
|
||||
static func getNatType(udpHole: SDLUDPHoleActor?, config: SDLConfiguration) async -> NatType {
|
||||
static func getNatType(udpHole: SDLUDPHole?, config: SDLConfiguration) async -> NatType {
|
||||
guard let udpHole else {
|
||||
return .blocked
|
||||
}
|
||||
@ -67,7 +67,7 @@ struct SDLNatProber {
|
||||
}
|
||||
}
|
||||
|
||||
private static func getNatAddress(_ udpHole: SDLUDPHoleActor, remoteAddress: SocketAddress, attr: SDLProbeAttr) async -> SocketAddress? {
|
||||
private static func getNatAddress(_ udpHole: SDLUDPHole, remoteAddress: SocketAddress, attr: SDLProbeAttr) async -> SocketAddress? {
|
||||
let stunProbeReply = try? await udpHole.stunProbe(remoteAddress: remoteAddress, attr: attr, timeout: 5)
|
||||
|
||||
return stunProbeReply?.socketAddress()
|
||||
|
||||
@ -10,7 +10,7 @@ import NIOCore
|
||||
import NIOPosix
|
||||
|
||||
// --MARK: 和SuperNode的客户端
|
||||
actor SDLSuperClientActor {
|
||||
actor SDLSuperClient {
|
||||
private let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
||||
private let asyncChannel: NIOAsyncChannel<ByteBuffer,ByteBuffer>
|
||||
private let (writeStream, writeContinuation) = AsyncStream.makeStream(of: TcpMessage.self, bufferingPolicy: .unbounded)
|
||||
@ -16,7 +16,7 @@ struct UDPMessage {
|
||||
}
|
||||
|
||||
// 处理和sn-server服务器之间的通讯
|
||||
actor SDLUDPHoleActor {
|
||||
actor SDLUDPHole {
|
||||
private let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
||||
private let asyncChannel: NIOAsyncChannel<AddressedEnvelope<ByteBuffer>, AddressedEnvelope<ByteBuffer>>
|
||||
private let (writeStream, continuation) = AsyncStream.makeStream(of: UDPMessage.self, bufferingPolicy: .unbounded)
|
||||
Loading…
x
Reference in New Issue
Block a user