添加资源http-dns实现
This commit is contained in:
@@ -9,8 +9,9 @@ public class WebSocketConstant {
|
||||
private static final String HOST_QA = "ws://62.234.196.121";
|
||||
private static final String HOST_DEMO = "ws://62.234.196.121";
|
||||
private static final String HOST_RELEASE = "ws://62.234.196.121";
|
||||
// private static final String PORT = ":14001/ws";
|
||||
public static final String PORT = ":4004/ws";
|
||||
// private static final String PORT = ":14001/ws";
|
||||
public static final String PATH = "/ws";
|
||||
public static final String PORT = ":4004"+PATH;
|
||||
public static final String PROTOCOL = "ws://";
|
||||
|
||||
private static final String DOMAIN_DEV = "dzt-city.zhidaozhixing.com";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.base.websocket;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.httpdns.HttpDnsConst;
|
||||
import com.mogo.httpdns.IMogoHttpDns;
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -27,22 +28,22 @@ public class WebSocketDnsManager {
|
||||
public void getHttpDnsIp(WebSocketDns webSocketDns) {
|
||||
this.webSocketDns = webSocketDns;
|
||||
IMogoHttpDns mogoHttpDns = ARouter.getInstance().navigation(IMogoHttpDns.class);
|
||||
ThreadPoolService.execute(() -> mogoHttpDns.getHttpDnsIp(WebSocketConstant.getDomain(), false, ip -> {
|
||||
ThreadPoolService.execute(() -> mogoHttpDns.getHttpDnsIp(WebSocketConstant.getDomain(), HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS,false, ip -> {
|
||||
Logger.d(TAG, "getHttpDnsIp ip : " + ip + " , 得到Dns IP,准备回调 初始化webSocket");
|
||||
this.cacheIp = ip;
|
||||
this.webSocketDns.getDnsIp((cacheIp != null ?
|
||||
WebSocketConstant.PROTOCOL + ip + WebSocketConstant.PORT :
|
||||
WebSocketConstant.PROTOCOL + ip + WebSocketConstant.PATH :
|
||||
WebSocketConstant.getSocketServer() + WebSocketConstant.PORT));
|
||||
}));
|
||||
mogoHttpDns.addHttpDnsTtlCallback(WebSocketConstant.getDomain(), () -> {
|
||||
mogoHttpDns.addHttpDnsTtlCallback(WebSocketConstant.getDomain(), HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS, () -> {
|
||||
Logger.d(TAG, "ttl callBack ,ready to getCache Dns IP");
|
||||
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(WebSocketConstant.getDomain());
|
||||
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(WebSocketConstant.getDomain(),HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS);
|
||||
if (dnsCacheIp == null) {
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG, "获取缓存Dns IP : " + dnsCacheIp + " , 原缓存 IP : " + cacheIp);
|
||||
if (cacheIp != null && !cacheIp.equals(dnsCacheIp)) {
|
||||
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.PORT);
|
||||
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.PATH);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user