diff --git a/Sources/Punchnet/SDLContext.swift b/Sources/Punchnet/SDLContext.swift index edf9bdf..9d330e6 100644 --- a/Sources/Punchnet/SDLContext.swift +++ b/Sources/Punchnet/SDLContext.swift @@ -120,7 +120,7 @@ public class SDLContext: @unchecked Sendable { do { try await self.startSuperClient() } catch let err { - NSLog("SuperClient get error: \(err)") + NSLog("[SDLContext] SuperClient get error: \(err), will restart") await self.arpServer.clear() try? await Task.sleep(for: .seconds(2)) } diff --git a/Sources/Punchnet/SDLSuperClient.swift b/Sources/Punchnet/SDLSuperClient.swift index ca86c77..5aafcc6 100644 --- a/Sources/Punchnet/SDLSuperClient.swift +++ b/Sources/Punchnet/SDLSuperClient.swift @@ -9,8 +9,6 @@ import Foundation import NIOCore import NIOPosix - - // --MARK: 和SuperNode的客户端 actor SDLSuperClient { private let group = MultiThreadedEventLoopGroup(numberOfThreads: 1) @@ -82,6 +80,7 @@ actor SDLSuperClient { } } } + NSLog("[SDLSuperClient] inbound closed") } group.addTask { @@ -92,6 +91,7 @@ actor SDLSuperClient { buffer.writeBytes(message.data) try await outbound.write(buffer) } + NSLog("[SDLSuperClient] outbound closed") } // --MARK: 心跳机制 @@ -100,6 +100,7 @@ actor SDLSuperClient { await self.ping() try? await Task.sleep(nanoseconds: 5 * 1_000_000_000) } + NSLog("[SDLSuperClient] heartbeat cancelled") } try await group.waitForAll()