change the socket register to fit demo environment

This commit is contained in:
zhongchao
2021-08-09 11:21:41 +08:00
parent 1effcfeb5e
commit 5b2465983a
7 changed files with 45 additions and 30 deletions

2
.idea/compiler.xml generated
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
<bytecodeTargetLevel target="1.8" />
</component>
</project>

6
.idea/gradle.xml generated
View File

@@ -1,17 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<<<<<<< HEAD
<option name="gradleJvm" value="11 (2)" />
=======
<option name="gradleJvm" value="Embedded JDK" />
>>>>>>> yingyan_location
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

7
.idea/misc.xml generated
View File

@@ -4,6 +4,7 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/ApiDoc" />
<option name="OPTION_DOCUMENT_TAG_USE" value="true" />
@@ -13,11 +14,7 @@
<option name="HEAP_SIZE" value="1024" />
<option name="LOCALE" value="zh_CN" />
</component>
<<<<<<< HEAD
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
=======
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
>>>>>>> yingyan_location
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@@ -30,22 +30,22 @@ PASSWORD=xintai2018
RELEASE=true
# AI CLOUD 云平台
# 工具类
MOGO_UTILS_VERSION=1.1.34
MOGO_UTILS_VERSION=1.1.35
# 网络请求
MOGO_NETWORK_VERSION=1.1.34
MOGO_NETWORK_VERSION=1.1.35
# 网络DNS
MOGO_HTTPDNS_VERSION=1.1.34
MOGO_HTTPDNS_VERSION=1.1.35
# 鉴权
MOGO_PASSPORT_VERSION=1.1.34
MOGO_PASSPORT_VERSION=1.1.35
# 常链接
MOGO_SOCKET_VERSION=1.1.34
MOGO_SOCKET_VERSION=1.1.35
# 数据采集
MOGO_REALTIME_VERSION=1.1.34
MOGO_REALTIME_VERSION=1.1.35
# 探路,道路事件发布,获取
MOGO_TANLU_VERSION=1.1.34
MOGO_TANLU_VERSION=1.1.35
# 直播推流
MOGO_LIVE_VERSION=1.1.34
MOGO_LIVE_VERSION=1.1.35
# 直播拉流
MOGO_TRAFFICLIVE_VERSION=1.1.34
MOGO_TRAFFICLIVE_VERSION=1.1.35
# 定位服务
MOGO_LOCATION_VERSION=1.1.34
MOGO_LOCATION_VERSION=1.1.35

View File

@@ -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; //演示环境通道
}

View File

@@ -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;
}
}
}

View File

@@ -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;