500ms上报数据增加cityCode

This commit is contained in:
tongchenfei
2020-12-20 11:22:50 +08:00
parent 47b81cc7e1
commit 3188d585d5
3 changed files with 24 additions and 3 deletions

View File

@@ -16,6 +16,8 @@ public class WebSocketData implements Serializable {
private long upUtcTime;
private String cityCode;
public long getSeq() {
return seq;
}
@@ -63,4 +65,12 @@ public class WebSocketData implements Serializable {
public void setUpUtcTime(long upUtcTime) {
this.upUtcTime = upUtcTime;
}
public String getCityCode() {
return cityCode;
}
public void setCityCode(String cityCode) {
this.cityCode = cityCode;
}
}

View File

@@ -8,6 +8,7 @@ import androidx.annotation.Keep;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mogo.commons.network.Utils;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.connection.IMogoMsgAckListener;
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
@@ -140,15 +141,20 @@ public class WebSocketManager implements IMogoWebSocketManager, ISocketMsgSettin
webSocketData.setMsgType(listener.getUpLinkType().getMsgType());
webSocketData.setSn(Utils.getSn());
webSocketData.setData(GsonUtil.jsonFromObject(body));
MogoLocation lastKnown = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(context).getLastKnowLocation();
if (lastKnown != null) {
webSocketData.setCityCode(lastKnown.getCityCode());
}
String msg = GsonUtil.jsonFromObject(webSocketData);
Logger.d(TAG,"sendMsg : " + msg);
handlerThread.sendMsg(msg);
}
}
private Context context;
@Override
public void init(Context context) {
this.context = context;
}
@Override

View File

@@ -28,12 +28,13 @@ public class DelayCheckUtil implements Handler.Callback {
private final Handler handler = new Handler(this);
private static final int MSG_CHECK_NET_CONNECT_STATUS = 1001;
private static final long FIRST_CHECK_NET_CONNECT_STATUS_DELAY = 10 * 60 * 1000;
private static final long CHECK_NET_CONNECT_STATUS_DELAY = 5000L;
private static final int MSG_START_DELAY_CHECK = 1002;
private static final long DELAY_CHECK_DELAY = 10 * 60 * 1000;
private Context context;
private final Context context;
public DelayCheckUtil(Context context) {
this.context = context;
@@ -43,7 +44,7 @@ public class DelayCheckUtil implements Handler.Callback {
* 每5s检查一下网络状态网络状态为连接状态时开始空接口请求以及后续的参数上报
*/
public void waitingForCheck() {
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, FIRST_CHECK_NET_CONNECT_STATUS_DELAY);
}
private long requestTime, netDelay;
@@ -85,11 +86,13 @@ public class DelayCheckUtil implements Handler.Callback {
@Override
public void onError(Throwable e) {
super.onError(e);
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
}
@Override
public void onError(String message, int code) {
super.onError(message, code);
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
}
});
}
@@ -110,11 +113,13 @@ public class DelayCheckUtil implements Handler.Callback {
@Override
public void onError(String message, int code) {
super.onError(message, code);
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
}
@Override
public void onError(Throwable e) {
super.onError(e);
handler.sendEmptyMessageDelayed(MSG_CHECK_NET_CONNECT_STATUS, CHECK_NET_CONNECT_STATUS_DELAY);
}
});
}