调试httpDns,修改上报时间间隔为500ms

This commit is contained in:
tongchenfei
2020-11-30 09:57:44 +08:00
parent 5b8957e7ce
commit 2eaf96533d
5 changed files with 42 additions and 15 deletions

View File

@@ -10,7 +10,13 @@ public class WebSocketConstant {
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";
private static final String PORT = ":4003/ws";
public static final String PORT = ":4003/ws";
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";
private static final String DOMAIN_RELEASE = "dzt-city.zhidaozhixing.com";
public static String getSocketServer() {
switch (DebugConfig.getNetMode()) {
@@ -26,7 +32,22 @@ public class WebSocketConstant {
}
}
public static String getSocketPort() {
return PORT;
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

@@ -27,20 +27,22 @@ public class WebSocketDnsManager {
public void getHttpDnsIp(WebSocketDns webSocketDns) {
this.webSocketDns = webSocketDns;
IMogoHttpDns mogoHttpDns = ARouter.getInstance().navigation(IMogoHttpDns.class);
ThreadPoolService.execute(() -> mogoHttpDns.getHttpDnsIp(WebSocketConstant.getSocketServer(), true, ip -> {
ThreadPoolService.execute(() -> mogoHttpDns.getHttpDnsIp(WebSocketConstant.getDomain(), false, ip -> {
Logger.d(TAG, "getHttpDnsIp ip : " + ip + " , 得到Dns IP,准备回调 初始化webSocket");
this.cacheIp = ip;
this.webSocketDns.getDnsIp((cacheIp != null ? cacheIp : WebSocketConstant.getSocketServer() + WebSocketConstant.getSocketPort()));
this.webSocketDns.getDnsIp((cacheIp != null ?
WebSocketConstant.PROTOCOL + ip + WebSocketConstant.PORT :
WebSocketConstant.getSocketServer() + WebSocketConstant.PORT));
}));
mogoHttpDns.addHttpDnsTtlCallback(WebSocketConstant.getSocketServer(), () -> {
mogoHttpDns.addHttpDnsTtlCallback(WebSocketConstant.getDomain(), () -> {
Logger.d(TAG, "ttl callBack ,ready to getCache Dns IP");
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(WebSocketConstant.getSocketServer());
String dnsCacheIp = mogoHttpDns.getCachedHttpDnsIps(WebSocketConstant.getDomain());
if (dnsCacheIp == null) {
return;
}
Logger.d(TAG, "获取缓存Dns IP : " + dnsCacheIp + " , 原缓存 IP " + cacheIp);
if (cacheIp != null && !cacheIp.equals(dnsCacheIp)) {
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.getSocketPort());
this.webSocketDns.ttlIp(dnsCacheIp + WebSocketConstant.PORT);
}
});
}

View File

@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static com.mogo.service.connection.WebSocketMsgType.MSG_TYPE_ACK;
import static com.mogo.service.connection.WebSocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
@Keep
@@ -181,11 +182,7 @@ public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSettin
WebSocketData webSocketData = GsonUtil.objectFromJson(message, WebSocketData.class);
int msgType = webSocketData.getMsgType();
Logger.d(TAG, "websocket received msg type = " + msgType);
if (webSocketData.getUtcTime() > 0) {
serverTime = webSocketData.getUtcTime();
receiveMsgTime = SystemClock.elapsedRealtime();
Logger.d(TAG, "设置serverTime");
}
//服务端下发数据返回,上传数据回执默认不返回
if (msgType == MSG_TYPE_DOWNLINK_CAR_DATA.getMsgType()) {
List<IMogoOnWebSocketMessageListener> listeners = mListeners.get(msgType);
@@ -200,6 +197,12 @@ public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSettin
}
}
}
} else if (msgType == MSG_TYPE_ACK.getMsgType()) {
if (webSocketData.getUtcTime() > 0) {
serverTime = webSocketData.getUtcTime();
receiveMsgTime = SystemClock.elapsedRealtime();
Logger.d(TAG, "设置serverTime");
}
}
}

View File

@@ -24,7 +24,7 @@ public class MogoRTKLocation {
private static final String TAG = "MogoRTKLocation";
private static final int MSG_DATA_CHANGED = 0x100;
private static final long MSG_DATA_INTERNAL = 1 * 1_000L;
private static final long MSG_DATA_INTERNAL = 500L;
private Handler mHandler;
private LocationManager locationManager;

View File

@@ -3,7 +3,8 @@ package com.mogo.service.connection;
public enum WebSocketMsgType {
MSG_TYPE_UPLINK_CAR_DATA(0,"自车与ADAS数据"),
MSG_TYPE_DOWNLINK_CAR_DATA(1,"服务端下发车辆信息");
MSG_TYPE_DOWNLINK_CAR_DATA(1,"服务端下发车辆信息"),
MSG_TYPE_ACK(3, "ACK");
private int msgType;
private String msg;