Skip to content

Commit

Permalink
Address the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Muxi Yan committed Oct 21, 2016
1 parent 72e9244 commit 0a18d64
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
11 changes: 3 additions & 8 deletions src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,7 @@ - (nullable instancetype)initWithReachability:(nullable SCNetworkReachabilityRef
if ((self = [super init])) {
_reachabilityRef = CFRetain(reachability);
_queue = dispatch_get_main_queue();
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) {
_previousReachabilityFlags =
[[GRPCReachabilityFlags alloc] initWithFlags:flags];
} else {
_previousReachabilityFlags = 0;
}
_previousReachabilityFlags = nil;
}
return self;
}
Expand All @@ -162,7 +156,8 @@ - (void)handleLossWithHandler:(void (^)())handler
[self startListeningWithHandler:^(GRPCReachabilityFlags *flags) {
if (!flags.reachable) {
handler();
} else if (flags.isWWAN ^ _previousReachabilityFlags.isWWAN) {
} else if (!_previousReachabilityFlags ||
(flags.isWWAN ^ _previousReachabilityFlags.isWAAN)) {
wifiStatusChangeHandler();
}
_previousReachabilityFlags = flags;
Expand Down
3 changes: 3 additions & 0 deletions src/objective-c/GRPCClient/private/GRPCHost.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ - (nullable instancetype)initWithAddress:(NSString *)address {
_secure = YES;
kHostCache[address] = self;

// When there is host in the cache, keep a single monitor to the network
// to
// flush the cache if the connectivity status changed
if (!connectivityMonitor) {
connectivityMonitor =
[GRPCConnectivityMonitor monitorWithHost:hostURL.host];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#endif

#if TARGET_OS_IPHONE
GRPC_XMACRO_ITEM(isCell, IsWWAN)
GRPC_XMACRO_ITEM(isWWAN, IsWWAN)
#endif
GRPC_XMACRO_ITEM(reachable, Reachable)
GRPC_XMACRO_ITEM(transientConnection, TransientConnection)
Expand All @@ -65,4 +65,3 @@ GRPC_XMACRO_ITEM(interventionRequired, InterventionRequired)
GRPC_XMACRO_ITEM(connectionOnDemand, ConnectionOnDemand)
GRPC_XMACRO_ITEM(isLocalAddress, IsLocalAddress)
GRPC_XMACRO_ITEM(isDirect, IsDirect)
GRPC_XMACRO_ITEM(isWWAN, IsWWAN)
1 change: 1 addition & 0 deletions src/objective-c/tests/Connectivity/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ target 'ConnectivityTestingApp' do
pod 'gRPC', :path => GRPC_LOCAL_SRC
pod 'gRPC-Core', :path => GRPC_LOCAL_SRC
pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC
pod 'gRPC-RxLibrary', :path => GRPC_LOCAL_SRC
pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf"
pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c"
end
Expand Down

0 comments on commit 0a18d64

Please sign in to comment.