Skip to content

Commit

Permalink
Prevent sendProviderMessage calls when not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed Jun 21, 2024
1 parent 5362ffc commit b0997a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public class ConnectionErrorObserverThroughSession: ConnectionErrorObserver {

private func handleStatusChangeNotification(_ notification: Notification) {
do {
guard let session = ConnectionSessionUtilities.session(from: notification) else {
guard let session = ConnectionSessionUtilities.session(from: notification),
session.status == .disconnected else {

return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public class ConnectionServerInfoObserverThroughSession: ConnectionServerInfoObs
// MARK: - Obtaining the NetP VPN status

private func updateServerInfo(session: NETunnelProviderSession) async {
guard session.status == .connected else {
return
}

let serverAddress = await self.serverAddress(from: session)
let serverLocation = await self.serverLocation(from: session)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public class DataVolumeObserverThroughSession: DataVolumeObserver {

private func updateDataVolume() {
Task {
guard let session = await tunnelSessionProvider.activeSession() else {
guard let session = await tunnelSessionProvider.activeSession(),
session.status == .connected else {

return
}

Expand Down

0 comments on commit b0997a0

Please sign in to comment.