Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 96fd61f

Browse files
author
mengyaoyao
committed
网络监听
1 parent 404d5a9 commit 96fd61f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

‎CocoaAsyncSocket_TCP/ChatHandler/ChatHandler.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,18 @@ - (void)networkChanged:(NSNotification *)notification {
326326

327327
// if (_connectStatus == SocketConnectStatus_DisconnectByUser) return; //主动断开连接
328328

329+
//网络中断 , 断开连接
329330
if (networkStatus == RealStatusNotReachable||_connectStatus == SocketConnectStatus_UnConnected) {
330331
[self serverInterruption];//断开连接,默认还会重连3次 ,还未连接自动断开
331332
}
333+
334+
//如果网络监测有网 , 但是socket处于未连接状态 , 进行重连
332335
if (networkStatus == RealStatusViaWWAN || networkStatus == RealStatusViaWiFi) {
333-
[self connectServerHost]; //连接服务器
336+
337+
if (_connectStatus == SocketConnectStatus_UnConnected) {
338+
339+
[self connectServerHost]; //连接服务器
340+
}
334341
}
335342
}
336343

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /