Address the comments

pull/8441/head
Muxi Yan 8 years ago
parent 72e92441f7
commit 0a18d64fcc
  1. 11
      src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
  2. 3
      src/objective-c/GRPCClient/private/GRPCHost.m
  3. 3
      src/objective-c/GRPCClient/private/GRPCReachabilityFlagNames.xmacro.h
  4. 1
      src/objective-c/tests/Connectivity/Podfile

@ -130,13 +130,7 @@ static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target,
if ((self = [super init])) { if ((self = [super init])) {
_reachabilityRef = CFRetain(reachability); _reachabilityRef = CFRetain(reachability);
_queue = dispatch_get_main_queue(); _queue = dispatch_get_main_queue();
SCNetworkReachabilityFlags flags; _previousReachabilityFlags = nil;
if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) {
_previousReachabilityFlags =
[[GRPCReachabilityFlags alloc] initWithFlags:flags];
} else {
_previousReachabilityFlags = 0;
}
} }
return self; return self;
} }
@ -162,7 +156,8 @@ static void PassFlagsToContextInfoBlock(SCNetworkReachabilityRef target,
[self startListeningWithHandler:^(GRPCReachabilityFlags *flags) { [self startListeningWithHandler:^(GRPCReachabilityFlags *flags) {
if (!flags.reachable) { if (!flags.reachable) {
handler(); handler();
} else if (flags.isWWAN ^ _previousReachabilityFlags.isWWAN) { } else if (!_previousReachabilityFlags ||
(flags.isWWAN ^ _previousReachabilityFlags.isWAAN)) {
wifiStatusChangeHandler(); wifiStatusChangeHandler();
} }
_previousReachabilityFlags = flags; _previousReachabilityFlags = flags;

@ -101,6 +101,9 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
_secure = YES; _secure = YES;
kHostCache[address] = self; 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) { if (!connectivityMonitor) {
connectivityMonitor = connectivityMonitor =
[GRPCConnectivityMonitor monitorWithHost:hostURL.host]; [GRPCConnectivityMonitor monitorWithHost:hostURL.host];

@ -55,7 +55,7 @@
#endif #endif
#if TARGET_OS_IPHONE #if TARGET_OS_IPHONE
GRPC_XMACRO_ITEM(isCell, IsWWAN) GRPC_XMACRO_ITEM(isWWAN, IsWWAN)
#endif #endif
GRPC_XMACRO_ITEM(reachable, Reachable) GRPC_XMACRO_ITEM(reachable, Reachable)
GRPC_XMACRO_ITEM(transientConnection, TransientConnection) GRPC_XMACRO_ITEM(transientConnection, TransientConnection)
@ -65,4 +65,3 @@ GRPC_XMACRO_ITEM(interventionRequired, InterventionRequired)
GRPC_XMACRO_ITEM(connectionOnDemand, ConnectionOnDemand) GRPC_XMACRO_ITEM(connectionOnDemand, ConnectionOnDemand)
GRPC_XMACRO_ITEM(isLocalAddress, IsLocalAddress) GRPC_XMACRO_ITEM(isLocalAddress, IsLocalAddress)
GRPC_XMACRO_ITEM(isDirect, IsDirect) GRPC_XMACRO_ITEM(isDirect, IsDirect)
GRPC_XMACRO_ITEM(isWWAN, IsWWAN)

@ -8,6 +8,7 @@ target 'ConnectivityTestingApp' do
pod 'gRPC', :path => GRPC_LOCAL_SRC pod 'gRPC', :path => GRPC_LOCAL_SRC
pod 'gRPC-Core', :path => GRPC_LOCAL_SRC pod 'gRPC-Core', :path => GRPC_LOCAL_SRC
pod 'gRPC-ProtoRPC', :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 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf"
pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c" pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c"
end end

Loading…
Cancel
Save