add new func of httpdns switch city to fit socketserver
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.httpdns.MogoHttpDnsHandler;
|
||||
@@ -7,6 +8,7 @@ import com.mogo.module.common.constants.HostConst;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
|
||||
public class WebSocketDnsManager {
|
||||
|
||||
private static final String TAG = "WebSocketDnsManager";
|
||||
@@ -16,7 +18,7 @@ public class WebSocketDnsManager {
|
||||
}
|
||||
|
||||
private static final class Holder {
|
||||
private static WebSocketDnsManager dnsManager = new WebSocketDnsManager();
|
||||
private static final WebSocketDnsManager dnsManager = new WebSocketDnsManager();
|
||||
}
|
||||
|
||||
public static WebSocketDnsManager getInstance() {
|
||||
@@ -36,7 +38,7 @@ public class WebSocketDnsManager {
|
||||
WebSocketConstant.PROTOCOL + ip + WebSocketConstant.PATH :
|
||||
WebSocketConstant.getSocketServer() + WebSocketConstant.PORT));
|
||||
}));
|
||||
mogoHttpDns.addHttpDnsTtlCallback(HostConst.WEBSOCKET_DOMAIN, HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS, () -> {
|
||||
mogoHttpDns.addressChangedListener(map -> {
|
||||
Logger.d(TAG, "ttl callBack ,ready to getCache Dns IP");
|
||||
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(HostConst.WEBSOCKET_DOMAIN, HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS);
|
||||
if (dnsCacheIp == null) {
|
||||
@@ -45,6 +47,7 @@ public class WebSocketDnsManager {
|
||||
Logger.d(TAG, "获取缓存Dns IP : " + dnsCacheIp + " , 原缓存 IP : " + cacheIp);
|
||||
if (cacheIp != null && !cacheIp.equals(dnsCacheIp)) {
|
||||
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.PATH);
|
||||
this.cacheIp = dnsCacheIp;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user