fix bug
This commit is contained in:
@@ -9,13 +9,13 @@ import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
import com.mogo.cloud.socket.MsgBody;
|
||||
import com.mogo.cloud.socket.SocketManager;
|
||||
import com.mogo.cloud.socket.WebSocketData;
|
||||
import com.mogo.realtime.Imp.RealTimeProviderImp;
|
||||
import com.mogo.realtime.core.SimpleLocationCorrectStrategy;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.realtime.entity.LocationResult;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.realtime.entity.OnePerSecondSendContent;
|
||||
import com.mogo.realtime.spi.RealTimeProviderImp;
|
||||
import com.mogo.realtime.util.MortonCode;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
@@ -51,20 +51,32 @@ public class SocketHandler {
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
/*
|
||||
* useInner: 是否注册自己内部的监听
|
||||
* */
|
||||
public void initSocket(Context context, String appId, IMogoCloudOnMsgListener listener) {
|
||||
/**
|
||||
* 初始化长连接服务
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param appId 外部传入
|
||||
*/
|
||||
public void initSocket(Context context, String appId) {
|
||||
SocketManager.getInstance().init(context, appId);
|
||||
SocketManager.getInstance().registerOnMessageListener(0x040002, onMessageListener);
|
||||
SocketManager.getInstance().registerOnMessageListener(0x040003, onMessageListener);
|
||||
if (listener != null && !onMsgListenerList.contains(listener)) {
|
||||
onMsgListenerList.add(listener);
|
||||
}
|
||||
|
||||
public void registerOnMsgListener(IMogoCloudOnMsgListener onMsgListener) {
|
||||
if (onMsgListener != null && !onMsgListenerList.contains(onMsgListener)) {
|
||||
onMsgListenerList.add(onMsgListener);
|
||||
}
|
||||
}
|
||||
|
||||
public void unRegisterOnMsgListener(IMogoCloudOnMsgListener onMsgListener) {
|
||||
if (onMsgListener != null) {
|
||||
onMsgListenerList.remove(onMsgListener);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetUploadDelayListener(IMogoCloudOnAckListener onAckListener) {
|
||||
if(onAckListener != null){
|
||||
if (onAckListener != null) {
|
||||
onAckListenerList.add(onAckListener);
|
||||
}
|
||||
}
|
||||
@@ -85,8 +97,10 @@ public class SocketHandler {
|
||||
if (webSocketData.getUpUtcTime() > 0) {
|
||||
long nextDelay = webSocketData.getUpUtcTime() - serverTime;
|
||||
if (!MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getIsUseExternalLocation()) {
|
||||
for (IMogoCloudOnAckListener ackListener:onAckListenerList) {
|
||||
ackListener.onAck(nextDelay);
|
||||
for (IMogoCloudOnAckListener ackListener : onAckListenerList) {
|
||||
if (ackListener != null) {
|
||||
ackListener.onAck(nextDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,15 +113,17 @@ public class SocketHandler {
|
||||
return;
|
||||
}
|
||||
for (IMogoCloudOnMsgListener listener : onMsgListenerList) {
|
||||
listener.onMsgReceived(data);
|
||||
if (listener != null) {
|
||||
listener.onMsgReceived(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void sendMsg(List<CloudLocationInfo> cloudLocationInfo) {
|
||||
if(cloudLocationInfo == null){
|
||||
Log.e(TAG,"请检查传入数组对象为Null");
|
||||
if (cloudLocationInfo == null) {
|
||||
Log.e(TAG, "请检查传入数组对象为Null");
|
||||
return;
|
||||
}
|
||||
CloudLocationInfo lastInfo = null;
|
||||
|
||||
Reference in New Issue
Block a user