diff --git a/Tun/PacketTunnelProvider.swift b/Tun/PacketTunnelProvider.swift index 0c08dc3..c554528 100644 --- a/Tun/PacketTunnelProvider.swift +++ b/Tun/PacketTunnelProvider.swift @@ -22,7 +22,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider { let msg = shared?.string(forKey: "test_msg") SDLLogger.log("NE read message: \(msg ?? "failed")", for: .debug) - DarwinNotificationCenter.shared.post(.vpnStatusChanged) + SDLNotificationCenter.shared.post(.vpnStatusChanged) // 如果当前在运行状态,不允许重复请求 guard self.contextActor == nil else { diff --git a/Tun/Punchnet/SDLTunnelAppNotifier.swift b/Tun/Punchnet/SDLTunnelAppNotifier.swift index 60a0b1f..6ab56fa 100644 --- a/Tun/Punchnet/SDLTunnelAppNotifier.swift +++ b/Tun/Punchnet/SDLTunnelAppNotifier.swift @@ -56,7 +56,7 @@ final class SDLTunnelAppNotifier { shared.set(data, forKey: self.eventKey) shared.synchronize() - DarwinNotificationCenter.shared.post(.tunnelEventChanged) + SDLNotificationCenter.shared.post(.tunnelEventChanged) } func clear() { @@ -66,6 +66,6 @@ final class SDLTunnelAppNotifier { shared.removeObject(forKey: self.eventKey) shared.synchronize() - DarwinNotificationCenter.shared.post(.tunnelEventChanged) + SDLNotificationCenter.shared.post(.tunnelEventChanged) } } diff --git a/punchnet/Core/DarwinNotificationCenter.swift b/punchnet/Core/SDLNotificationCenter.swift similarity index 94% rename from punchnet/Core/DarwinNotificationCenter.swift rename to punchnet/Core/SDLNotificationCenter.swift index 11b01c6..a94cda7 100644 --- a/punchnet/Core/DarwinNotificationCenter.swift +++ b/punchnet/Core/SDLNotificationCenter.swift @@ -23,8 +23,8 @@ extension DarwinNotificationName { // MARK: - Manager -public final class DarwinNotificationCenter { - public static let shared = DarwinNotificationCenter() +public final class SDLNotificationCenter { + public static let shared = SDLNotificationCenter() private let center = CFNotificationCenterGetDarwinNotifyCenter() @@ -50,7 +50,7 @@ public final class DarwinNotificationCenter { return } - let instance = Unmanaged + let instance = Unmanaged .fromOpaque(observer) .takeUnretainedValue() diff --git a/punchnet/punchnetApp.swift b/punchnet/punchnetApp.swift index 641949e..64ef2c7 100644 --- a/punchnet/punchnetApp.swift +++ b/punchnet/punchnetApp.swift @@ -93,7 +93,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { shared?.set("App says hello", forKey: "test_msg") shared?.synchronize() - DarwinNotificationCenter.shared.addObserver(for: .vpnStatusChanged) { name in + SDLNotificationCenter.shared.addObserver(for: .vpnStatusChanged) { name in NSLog("DarwinNotificationCenter get message: \(name)") } }