mirror of
https://github.com/WuKongIM/WuKongIMAndroidSDK
synced 2025-06-09 19:37:12 +00:00
fix:update connection
This commit is contained in:
parent
5e507404b2
commit
19a5b5f207
@ -6,8 +6,8 @@ import com.xinbida.wukongim.WKIM;
|
|||||||
import com.xinbida.wukongim.WKIMApplication;
|
import com.xinbida.wukongim.WKIMApplication;
|
||||||
import com.xinbida.wukongim.interfaces.IConnectionStatus;
|
import com.xinbida.wukongim.interfaces.IConnectionStatus;
|
||||||
import com.xinbida.wukongim.interfaces.IGetIpAndPort;
|
import com.xinbida.wukongim.interfaces.IGetIpAndPort;
|
||||||
import com.xinbida.wukongim.message.WKConnection;
|
|
||||||
import com.xinbida.wukongim.message.MessageHandler;
|
import com.xinbida.wukongim.message.MessageHandler;
|
||||||
|
import com.xinbida.wukongim.message.WKConnection;
|
||||||
import com.xinbida.wukongim.utils.WKLoggerUtils;
|
import com.xinbida.wukongim.utils.WKLoggerUtils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -91,7 +91,7 @@ public class WKConnection {
|
|||||||
private String lastRequestId;
|
private String lastRequestId;
|
||||||
private int unReceivePongCount = 0;
|
private int unReceivePongCount = 0;
|
||||||
public volatile Handler reconnectionHandler = new Handler(Objects.requireNonNull(Looper.myLooper()));
|
public volatile Handler reconnectionHandler = new Handler(Objects.requireNonNull(Looper.myLooper()));
|
||||||
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
// private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable reconnectionRunnable = this::reconnection;
|
Runnable reconnectionRunnable = this::reconnection;
|
||||||
private int connCount = 0;
|
private int connCount = 0;
|
||||||
|
|
||||||
@ -166,6 +166,7 @@ public class WKConnection {
|
|||||||
closeConnect();
|
closeConnect();
|
||||||
socketSingleID = UUID.randomUUID().toString().replace("-", "");
|
socketSingleID = UUID.randomUUID().toString().replace("-", "");
|
||||||
connectionClient = new ConnectionClient(iNonBlockingConnection -> {
|
connectionClient = new ConnectionClient(iNonBlockingConnection -> {
|
||||||
|
connCount = 0;
|
||||||
if (iNonBlockingConnection == null || connection == null || !connection.getId().equals(iNonBlockingConnection.getId())) {
|
if (iNonBlockingConnection == null || connection == null || !connection.getId().equals(iNonBlockingConnection.getId())) {
|
||||||
forcedReconnection();
|
forcedReconnection();
|
||||||
return;
|
return;
|
||||||
@ -508,7 +509,6 @@ public class WKConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void closeConnect() {
|
private synchronized void closeConnect() {
|
||||||
mainHandler.post(() -> {
|
|
||||||
if (connection != null && connection.isOpen()) {
|
if (connection != null && connection.isOpen()) {
|
||||||
try {
|
try {
|
||||||
WKLoggerUtils.getInstance().e("stop connection:" + connection.getId());
|
WKLoggerUtils.getInstance().e("stop connection:" + connection.getId());
|
||||||
@ -520,11 +520,7 @@ public class WKConnection {
|
|||||||
} finally {
|
} finally {
|
||||||
connection = null;
|
connection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Timer checkNetWorkTimer;
|
private Timer checkNetWorkTimer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user