diff --git a/build.gradle b/build.gradle index 1955f29..a1f1c79 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ apply from: "config.gradle" buildscript { ext.kotlin_version = "1.4.31" repositories { - gradlePluginPortal() + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } @@ -15,6 +15,7 @@ buildscript { url 'http://nexus.zhidaoauto.com/repository/maven-public/' } google() + gradlePluginPortal() } dependencies { classpath "com.android.tools.build:gradle:3.5.3" @@ -30,7 +31,7 @@ buildscript { allprojects { repositories { - gradlePluginPortal() + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } @@ -41,6 +42,7 @@ allprojects { url 'http://nexus.zhidaoauto.com/repository/maven-public/' } google() + gradlePluginPortal() } } diff --git a/gradle.properties b/gradle.properties index ff1644f..eee34a4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -36,26 +36,26 @@ PASSWORD=xintai2018 RELEASE=true # AI CLOUD 云平台 # 工具类 -MOGO_UTILS_VERSION=1.4.3.5 +MOGO_UTILS_VERSION=1.4.3.6 # 网络请求 -MOGO_NETWORK_VERSION=1.4.3.5 +MOGO_NETWORK_VERSION=1.4.3.6 # 网络DNS -MOGO_HTTPDNS_VERSION=1.4.3.5 +MOGO_HTTPDNS_VERSION=1.4.3.6 # 鉴权 -MOGO_PASSPORT_VERSION=1.4.3.5 +MOGO_PASSPORT_VERSION=1.4.3.6 # 常链接 -MOGO_SOCKET_VERSION=1.4.3.5 +MOGO_SOCKET_VERSION=1.4.3.6 # 数据采集 -MOGO_REALTIME_VERSION=1.4.3.5 +MOGO_REALTIME_VERSION=1.4.3.6 # 探路,道路事件发布,获取 -MOGO_TANLU_VERSION=1.4.3.5 +MOGO_TANLU_VERSION=1.4.3.6 # 直播推流 -MOGO_LIVE_VERSION=1.4.3.5 +MOGO_LIVE_VERSION=1.4.3.6 # 直播拉流 -MOGO_TRAFFICLIVE_VERSION=1.4.3.5 +MOGO_TRAFFICLIVE_VERSION=1.4.3.6 # 定位服务 -MOGO_LOCATION_VERSION=1.4.3.5 +MOGO_LOCATION_VERSION=1.4.3.6 # 远程通讯模块 -MOGO_TELEMATIC_VERSION=1.4.3.5 +MOGO_TELEMATIC_VERSION=1.4.3.6 # v2x -MOGO_V2X_VERSION=1.4.3.5 +MOGO_V2X_VERSION=1.4.3.6 diff --git a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/server/NSDServer.java b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/server/NSDServer.java index c6d1d81..306c082 100644 --- a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/server/NSDServer.java +++ b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/server/NSDServer.java @@ -13,6 +13,8 @@ public class NSDServer { private String mServerName; private final String mServerType = "_http._tcp."; // 服务器type,要客户端扫描服务器的一致 + private boolean isRegister; + public NSDServer() { } @@ -27,6 +29,7 @@ public class NSDServer { @Override public void onRegistrationFailed(NsdServiceInfo serviceInfo, int errorCode) { Logger.e(TAG, "NsdServiceInfo onRegistrationFailed"); + isRegister = false; if (registerState != null) { registerState.onRegistrationFailed(serviceInfo, errorCode); } @@ -35,6 +38,7 @@ public class NSDServer { @Override public void onUnregistrationFailed(NsdServiceInfo serviceInfo, int errorCode) { Logger.i(TAG, "onUnregistrationFailed serviceInfo: " + serviceInfo + " ,errorCode:" + errorCode); + isRegister = false; if (registerState != null) { registerState.onUnRegistrationFailed(serviceInfo, errorCode); } @@ -53,6 +57,7 @@ public class NSDServer { @Override public void onServiceUnregistered(NsdServiceInfo serviceInfo) { Logger.i(TAG, "onServiceUnregistered serviceInfo: " + serviceInfo); + isRegister = false; if (registerState != null) { registerState.onServiceUnregistered(serviceInfo); } @@ -67,10 +72,13 @@ public class NSDServer { serviceInfo.setPort(port); serviceInfo.setServiceType(mServerType); mNsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener); + isRegister = true; } public void stopNSDServer() { - if (mNsdManager != null) { + // 部分失败的回调会从map中移除key,解注册时查不到则会出现异常 + // 添加isRegister判断 + if (mNsdManager != null && isRegister) { mNsdManager.unregisterService(mRegistrationListener); } }