Skip to content
Snippets Groups Projects
Commit ad93106d authored by Muxi Yan's avatar Muxi Yan
Browse files

Keep a singleton of connectivity monitor in GRPCHost

parent 6ac6a52d
No related branches found
No related tags found
No related merge requests found
...@@ -100,19 +100,16 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil; ...@@ -100,19 +100,16 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
_address = address; _address = address;
_secure = YES; _secure = YES;
kHostCache[address] = self; kHostCache[address] = self;
}
// When there is host in the cache, keep a single monitor to the network // Keep a single monitor to flush the cache if the connectivity status changed
// to if (!connectivityMonitor) {
// flush the cache if the connectivity status changed connectivityMonitor =
if (!connectivityMonitor) { [GRPCConnectivityMonitor monitorWithHost:hostURL.host];
connectivityMonitor = void (^handler)() = ^{
[GRPCConnectivityMonitor monitorWithHost:hostURL.host]; [GRPCHost flushChannelCache];
void (^handler)() = ^{ };
[GRPCHost flushChannelCache]; [connectivityMonitor handleLossWithHandler:handler
}; wifiStatusChangeHandler:handler];
[connectivityMonitor handleLossWithHandler:handler
wifiStatusChangeHandler:handler];
}
} }
} }
return self; return self;
...@@ -125,8 +122,6 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil; ...@@ -125,8 +122,6 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil;
BOOL * _Nonnull stop) { BOOL * _Nonnull stop) {
[host disconnect]; [host disconnect];
}]; }];
[kHostCache removeAllObjects];
connectivityMonitor = nil;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment