change the socket register to fit demo environment
This commit is contained in:
@@ -5,4 +5,7 @@ public class RealTimeConstant {
|
||||
public static final String TAG = "MoGoAiCloud_RealTime";
|
||||
public static final int HIGH_FREQUENCY_CHANNEL_ID = 0x040002; //高频数据
|
||||
public static final int LOW_FREQUENCY_CHANNEL_ID = 0x040003; //低频数据
|
||||
public static final int DEMO_FREQUENCY_CHANNEL_ID = 0x040004; //演示环境通道
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.mogo.realtime.core;
|
||||
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEMO;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.socket.entity.MsgBody;
|
||||
import com.mogo.realtime.constant.RealTimeConstant;
|
||||
import com.mogo.realtime.entity.SocketReceiveDataProto3;
|
||||
@@ -61,9 +64,17 @@ public class SnapshotUploadInTime implements UploadInTimeHandler.IUploadInTimeLi
|
||||
RealTimeProviderImp.getInstance().getLocationMsg();//SPI接口返回
|
||||
if (socketReceiveDataProto != null) {
|
||||
MsgBody msgBody = new MsgBody();
|
||||
msgBody.msgType(RealTimeConstant.HIGH_FREQUENCY_CHANNEL_ID);
|
||||
msgBody.msgType(getMsgType());
|
||||
msgBody.content(socketReceiveDataProto.toByteArray());
|
||||
SocketHandler.getInstance().sendMsg(msgBody);
|
||||
}
|
||||
}
|
||||
|
||||
private int getMsgType() {
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getNetMode() == HTTP_DNS_ENV_DEMO) {
|
||||
return RealTimeConstant.DEMO_FREQUENCY_CHANNEL_ID;
|
||||
} else {
|
||||
return RealTimeConstant.HIGH_FREQUENCY_CHANNEL_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.mogo.realtime.socket;
|
||||
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEMO;
|
||||
import static com.mogo.cloud.socket.SocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
|
||||
import static com.mogo.realtime.constant.RealTimeConstant.TAG;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
import com.mogo.cloud.socket.SocketManager;
|
||||
import com.mogo.cloud.socket.entity.MsgBody;
|
||||
@@ -13,9 +18,6 @@ import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.cloud.socket.SocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
|
||||
import static com.mogo.realtime.constant.RealTimeConstant.TAG;
|
||||
|
||||
/**
|
||||
* Socket长链 业务服务处理类
|
||||
*/
|
||||
@@ -48,8 +50,12 @@ public class SocketHandler {
|
||||
public void initSocket(Context context, String appId) {
|
||||
mAppId = appId;
|
||||
SocketManager.getInstance().init(context);
|
||||
SocketManager.getInstance().registerOnMessageListener(RealTimeConstant.HIGH_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().registerOnMessageListener(RealTimeConstant.LOW_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getNetMode() == HTTP_DNS_ENV_DEMO) {
|
||||
SocketManager.getInstance().registerOnMessageListener(RealTimeConstant.DEMO_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
} else {
|
||||
SocketManager.getInstance().registerOnMessageListener(RealTimeConstant.HIGH_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().registerOnMessageListener(RealTimeConstant.LOW_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerOnMsgListener(IMogoCloudOnMsgListener onMsgListener) {
|
||||
@@ -102,8 +108,12 @@ public class SocketHandler {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
SocketManager.getInstance().unregisterOnMessageListener(RealTimeConstant.HIGH_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().unregisterOnMessageListener(RealTimeConstant.LOW_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getNetMode() == HTTP_DNS_ENV_DEMO) {
|
||||
SocketManager.getInstance().unregisterOnMessageListener(RealTimeConstant.DEMO_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
} else {
|
||||
SocketManager.getInstance().unregisterOnMessageListener(RealTimeConstant.HIGH_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().unregisterOnMessageListener(RealTimeConstant.LOW_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
}
|
||||
SocketManager.getInstance().release();
|
||||
onMsgListenerList.clear();
|
||||
mInstance = null;
|
||||
|
||||
Reference in New Issue
Block a user