Merge dev_mogo_httpdns

there are some conflicts:
 both modified:   foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java
        both modified:   gradle.properties
        both modified:   modules/mogo-module-share/consumer-rules.pro
        both modified:   modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt
This commit is contained in:
tongchenfei
2021-01-14 14:45:53 +08:00
43 changed files with 800 additions and 703 deletions

View File

@@ -21,12 +21,6 @@ public class WebSocketConstant {
@Keep
public static final String PROTOCOL = "ws://";
private static final String DOMAIN_DEV = "dzt-city.zhidaozhixing.com";
private static final String DOMAIN_QA = "dzt-city.zhidaozhixing.com";
private static final String DOMAIN_DEMO = "dzt-city.zhidaozhixing.com";
@Keep
private static final String DOMAIN_RELEASE = "dzt-city.zhidaozhixing.com";
public static String getSocketServer() {
switch (DebugConfig.getNetMode()) {
case DebugConfig.NET_MODE_DEV:
@@ -41,19 +35,6 @@ public class WebSocketConstant {
}
}
public static String getDomain(){
switch (DebugConfig.getNetMode()) {
case DebugConfig.NET_MODE_DEV:
return DOMAIN_DEV;
case DebugConfig.NET_MODE_QA:
return DOMAIN_QA;
case DebugConfig.NET_MODE_DEMO:
return DOMAIN_DEMO;
case DebugConfig.NET_MODE_RELEASE:
default:
return DOMAIN_RELEASE;
}
}
// public static String getSocketPort() {
// return PORT;

View File

@@ -1,8 +1,9 @@
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.httpdns.MogoHttpDnsHandler;
import com.mogo.module.common.constants.HostConst;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.logger.Logger;
@@ -27,17 +28,17 @@ public class WebSocketDnsManager {
public void getHttpDnsIp(WebSocketDns webSocketDns) {
this.webSocketDns = webSocketDns;
IMogoHttpDns mogoHttpDns = ARouter.getInstance().navigation(IMogoHttpDns.class);
ThreadPoolService.execute(() -> mogoHttpDns.getHttpDnsIp(WebSocketConstant.getDomain(), HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS,false, ip -> {
IMogoHttpDns mogoHttpDns = MogoHttpDnsHandler.getHttpDnsApi();
ThreadPoolService.execute(() -> mogoHttpDns.getHttpDnsIp(HostConst.WEBSOCKET_DOMAIN, 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.PATH :
WebSocketConstant.getSocketServer() + WebSocketConstant.PORT));
}));
mogoHttpDns.addHttpDnsTtlCallback(WebSocketConstant.getDomain(), HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS, () -> {
mogoHttpDns.addHttpDnsTtlCallback(HostConst.WEBSOCKET_DOMAIN, HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS, () -> {
Logger.d(TAG, "ttl callBack ,ready to getCache Dns IP");
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(WebSocketConstant.getDomain(),HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS);
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(HostConst.WEBSOCKET_DOMAIN, HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_WS);
if (dnsCacheIp == null) {
return;
}

View File

@@ -79,6 +79,9 @@ public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSettin
@Override
public void ttlIp(String url) {
Logger.d(TAG,"ttlIp url : " + url);
if(!WebSocketInstanceHolder.getClientProxy().isOpen()){
return;
}
WebSocketInstanceHolder.getClientProxy().stop();
WebSocketInstanceHolder.getClientProxy().disConnect();
Logger.d(TAG,"ready to re initWebSocket : " + url);