fix 通知中心

This commit is contained in:
anlicheng 2026-04-15 10:37:45 +08:00
parent ac01e68311
commit 98386ded25
4 changed files with 7 additions and 7 deletions

View File

@ -22,7 +22,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
let msg = shared?.string(forKey: "test_msg") let msg = shared?.string(forKey: "test_msg")
SDLLogger.log("NE read message: \(msg ?? "failed")", for: .debug) SDLLogger.log("NE read message: \(msg ?? "failed")", for: .debug)
DarwinNotificationCenter.shared.post(.vpnStatusChanged) SDLNotificationCenter.shared.post(.vpnStatusChanged)
// //
guard self.contextActor == nil else { guard self.contextActor == nil else {

View File

@ -56,7 +56,7 @@ final class SDLTunnelAppNotifier {
shared.set(data, forKey: self.eventKey) shared.set(data, forKey: self.eventKey)
shared.synchronize() shared.synchronize()
DarwinNotificationCenter.shared.post(.tunnelEventChanged) SDLNotificationCenter.shared.post(.tunnelEventChanged)
} }
func clear() { func clear() {
@ -66,6 +66,6 @@ final class SDLTunnelAppNotifier {
shared.removeObject(forKey: self.eventKey) shared.removeObject(forKey: self.eventKey)
shared.synchronize() shared.synchronize()
DarwinNotificationCenter.shared.post(.tunnelEventChanged) SDLNotificationCenter.shared.post(.tunnelEventChanged)
} }
} }

View File

@ -23,8 +23,8 @@ extension DarwinNotificationName {
// MARK: - Manager // MARK: - Manager
public final class DarwinNotificationCenter { public final class SDLNotificationCenter {
public static let shared = DarwinNotificationCenter() public static let shared = SDLNotificationCenter()
private let center = CFNotificationCenterGetDarwinNotifyCenter() private let center = CFNotificationCenterGetDarwinNotifyCenter()
@ -50,7 +50,7 @@ public final class DarwinNotificationCenter {
return return
} }
let instance = Unmanaged<DarwinNotificationCenter> let instance = Unmanaged<SDLNotificationCenter>
.fromOpaque(observer) .fromOpaque(observer)
.takeUnretainedValue() .takeUnretainedValue()

View File

@ -93,7 +93,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
shared?.set("App says hello", forKey: "test_msg") shared?.set("App says hello", forKey: "test_msg")
shared?.synchronize() shared?.synchronize()
DarwinNotificationCenter.shared.addObserver(for: .vpnStatusChanged) { name in SDLNotificationCenter.shared.addObserver(for: .vpnStatusChanged) { name in
NSLog("DarwinNotificationCenter get message: \(name)") NSLog("DarwinNotificationCenter get message: \(name)")
} }
} }