mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2024-10-06 17:22:07 +08:00
Implement abstract tracker class
This commit is contained in:
parent
a9629cdf86
commit
d2d46640db
21
OpenVPN Adapter/OpenVPNReachabilityTracker.h
Normal file
21
OpenVPN Adapter/OpenVPNReachabilityTracker.h
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// OpenVPNReachabilityTracker.h
|
||||
// OpenVPN Adapter
|
||||
//
|
||||
// Created by Sergey Abramchuk on 17.07.17.
|
||||
//
|
||||
//
|
||||
|
||||
#import <openvpn/apple/reachable.hpp>
|
||||
|
||||
using namespace openvpn;
|
||||
|
||||
class OpenVPNReachabilityTracker : public ReachabilityTracker {
|
||||
OpenVPNReachabilityTracker(const bool enable_internet, const bool enable_wifi, void* handler);
|
||||
|
||||
virtual void reachability_tracker_event(const ReachabilityBase& rb, SCNetworkReachabilityFlags flags) override;
|
||||
|
||||
private:
|
||||
void* handler;
|
||||
|
||||
};
|
33
OpenVPN Adapter/OpenVPNReachabilityTracker.mm
Normal file
33
OpenVPN Adapter/OpenVPNReachabilityTracker.mm
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// OpenVPNReachabilityTracker.m
|
||||
// OpenVPN Adapter
|
||||
//
|
||||
// Created by Sergey Abramchuk on 17.07.17.
|
||||
//
|
||||
//
|
||||
|
||||
#import "OpenVPNReachability+Internal.h"
|
||||
#import "OpenVPNReachabilityTracker.h"
|
||||
|
||||
OpenVPNReachabilityTracker::OpenVPNReachabilityTracker(const bool enable_internet, const bool enable_wifi, void* handler) : ReachabilityTracker(enable_internet, enable_wifi) {
|
||||
this->handler = handler;
|
||||
}
|
||||
|
||||
void OpenVPNReachabilityTracker::reachability_tracker_event(const ReachabilityBase& rb, SCNetworkReachabilityFlags flags) {
|
||||
OpenVPNReachability* handler = (__bridge OpenVPNReachability* )this->handler;
|
||||
|
||||
ReachabilityInterface::Status status = rb.status();
|
||||
switch (status) {
|
||||
case ReachabilityInterface::NotReachable:
|
||||
[handler updateReachabilityStatus:OpenVPNReachabilityStatusNotReachable];
|
||||
break;
|
||||
|
||||
case ReachabilityInterface::ReachableViaWiFi:
|
||||
[handler updateReachabilityStatus:OpenVPNReachabilityStatusReachableViaWiFi];
|
||||
break;
|
||||
|
||||
case ReachabilityInterface::ReachableViaWWAN:
|
||||
[handler updateReachabilityStatus:OpenVPNReachabilityStatusReachableViaWWAN];
|
||||
break;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user