merge
This commit is contained in:
4
.idea/gradle.xml
generated
4
.idea/gradle.xml
generated
@@ -7,7 +7,11 @@
|
||||
<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$" />
|
||||
|
||||
4
.idea/misc.xml
generated
4
.idea/misc.xml
generated
@@ -13,7 +13,11 @@
|
||||
<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
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.support.multidex.MultiDexApplication;
|
||||
import android.util.Log;
|
||||
|
||||
import com.auto.zhidao.logsdk.CrashSystem;
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsClient;
|
||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||
import com.mogo.cloud.httpdns.bean.HttpDnsSimpleLocation;
|
||||
import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation;
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.mogo.cloud.httpdns.util.ApiManager
|
||||
import com.mogo.cloud.httpdns.util.L
|
||||
import com.mogo.cloud.httpdns.util.NetWorkUtil
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
/**
|
||||
* 1. 本地每15min查询一次
|
||||
@@ -18,7 +17,8 @@ import kotlin.collections.ArrayList
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.Callback,IMogoHttpDns {
|
||||
internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.Callback,
|
||||
IMogoHttpDns {
|
||||
companion object {
|
||||
const val HTTP_DNS_TYPE_HTTP = 0
|
||||
const val HTTP_DNS_TYPE_WS = 1
|
||||
@@ -34,12 +34,10 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
||||
private val workThread = HandlerThread("mogo-http-dns-work-thread")
|
||||
private val handler: Handler
|
||||
private var addressMap: Map<String, String>? = null
|
||||
|
||||
var addressChangedListener: OnAddressChangedListener? = null
|
||||
private var addressChangedListener: OnAddressChangedListener? = null
|
||||
|
||||
private val apiManager: ApiManager
|
||||
private var isInit = false
|
||||
|
||||
private var defaultUrl: String? = null
|
||||
|
||||
init {
|
||||
@@ -65,7 +63,6 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
||||
}
|
||||
|
||||
private fun getHttpDnsAddressFromNet() {
|
||||
|
||||
val nAddress = apiManager.requestHttpDns(builder.getCurrentLocation()!!)
|
||||
if (addressChangedListener == null) {
|
||||
L.d(TAG, "addressChangeList is null")
|
||||
@@ -74,8 +71,8 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
||||
addressMap = nAddress
|
||||
addressChangedListener?.onAddressChanged(addressMap)
|
||||
} else if (nAddress != null) {
|
||||
addressChangedListener?.onAddressChanged(mapDiff(nAddress, addressMap!!))
|
||||
addressMap = nAddress
|
||||
addressChangedListener?.onAddressChanged(mapDiff(nAddress, addressMap!!))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,15 +83,35 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
||||
|
||||
private val requestLock = Any()
|
||||
|
||||
override fun addressChangedListener(addressChangedListener: OnAddressChangedListener) {
|
||||
this.addressChangedListener = addressChangedListener
|
||||
}
|
||||
|
||||
override fun syncGetHttpDns(host: String, type: Int, useCache: Boolean): String? {
|
||||
L.d(TAG, "syncGetHttpDns $type-$host")
|
||||
return if (useCache) {
|
||||
val address: String? = getHttpDnsCachedAddress(type, host)
|
||||
address ?: getHttpDnsAddress(type, host)
|
||||
} else {
|
||||
getHttpDnsAddress(type, host)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getHttpDnsAddress(type: Int, _host: String): String? {
|
||||
val host = _host.toLowerCase(Locale.getDefault())
|
||||
if (isInit) {
|
||||
requestCache.add("$type-$host")
|
||||
synchronized(requestLock) {
|
||||
L.d(TAG, "getHttpDnsAddress: $type-$host \n thread: ${Thread.currentThread().name} isRequest: $isRequest")
|
||||
L.d(
|
||||
TAG,
|
||||
"getHttpDnsAddress: $type-$host \n thread: ${Thread.currentThread().name} isRequest: $isRequest"
|
||||
)
|
||||
if (!isRequest) {
|
||||
isRequest = true
|
||||
L.d(TAG, "prepare to get http dns from net thread: ${Thread.currentThread().name}")
|
||||
L.d(
|
||||
TAG,
|
||||
"prepare to get http dns from net thread: ${Thread.currentThread().name}"
|
||||
)
|
||||
getHttpDnsAddressFromNet()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.cloud.httpdns
|
||||
|
||||
import com.mogo.cloud.httpdns.listener.IMogoHttpDns
|
||||
import com.mogo.cloud.httpdns.listener.OnAddressChangedListener
|
||||
|
||||
|
||||
object MogoHttpDnsClient : IMogoHttpDns {
|
||||
@@ -20,6 +21,20 @@ object MogoHttpDnsClient : IMogoHttpDns {
|
||||
return getHttpDnsCachedAddress(type, _host) ?: return getHttpDnsAddress(type, _host)
|
||||
}
|
||||
|
||||
override fun addressChangedListener(addressChangedListener: OnAddressChangedListener) {
|
||||
if (httpDnsHelper == null) {
|
||||
throw IllegalStateException("MogoHttpDnsClient init error")
|
||||
}
|
||||
return httpDnsHelper!!.addressChangedListener(addressChangedListener)
|
||||
}
|
||||
|
||||
override fun syncGetHttpDns(host: String, type: Int, useCache: Boolean): String? {
|
||||
if (httpDnsHelper == null) {
|
||||
throw IllegalStateException("MogoHttpDnsClient init error")
|
||||
}
|
||||
return httpDnsHelper!!.syncGetHttpDns(host, type, useCache)
|
||||
}
|
||||
|
||||
override fun getHttpDnsAddress(type: Int, _host: String): String? {
|
||||
if (httpDnsHelper == null) {
|
||||
throw IllegalStateException("MogoHttpDnsClient init error")
|
||||
|
||||
@@ -3,6 +3,22 @@ package com.mogo.cloud.httpdns.listener
|
||||
import com.mogo.cloud.httpdns.HttpDnsHelper.Companion.HTTP_DNS_TYPE_HTTP
|
||||
|
||||
interface IMogoHttpDns {
|
||||
|
||||
/**
|
||||
* 地址变更回调
|
||||
*/
|
||||
fun addressChangedListener(addressChangedListener: OnAddressChangedListener);
|
||||
|
||||
/**
|
||||
* 同步进行dns解析,无需回调
|
||||
* @param host
|
||||
* @param type
|
||||
* @param useCache
|
||||
*
|
||||
* @return ip:port
|
||||
*/
|
||||
fun syncGetHttpDns(host: String, type: Int, useCache: Boolean): String?
|
||||
|
||||
/**
|
||||
* 根据类型和host获取IP,直接通过网络请求获取全部路由表
|
||||
* 同时多线程多次请求会忽略部分网络请求,一定程度减少接口请求次数
|
||||
|
||||
@@ -26,6 +26,8 @@ class NetConstants {
|
||||
|
||||
const val TECH_HOST = "http://tech-dev.zhidaozhixing.com"
|
||||
|
||||
const val MecEtl_HOST = "http://dzt-mecEtl.zhidaozhixing.com"
|
||||
|
||||
|
||||
const val IM_SOCKET_DOMAIN = "dzt-im.zhidaozhixing.com"
|
||||
const val WEBSOCKET_DOMAIN = "dzt-Instant.zhidaozhixing.com"
|
||||
|
||||
@@ -100,11 +100,6 @@ public class MoGoAiCloudClient {
|
||||
mAiCloudClientConfig.setToken(token);
|
||||
}
|
||||
|
||||
// 循环调用将数据传出去
|
||||
for (IMoGoTokenCallback tokenCallback : mTokenCallbacks) {
|
||||
tokenCallback.onTokenGot(token, sn);
|
||||
}
|
||||
|
||||
// 初始化HttpDNS
|
||||
mHttpDnsConfig =
|
||||
new MogoHttpDnsConfig()
|
||||
@@ -115,6 +110,11 @@ public class MoGoAiCloudClient {
|
||||
.setCurrentLocation(mAiCloudClientConfig.getIHttpDnsCurrentLocation())
|
||||
.setLoopCheckDelay(mAiCloudClientConfig.getLoopCheckDelay());
|
||||
MogoHttpDnsClient.INSTANCE.init(mHttpDnsConfig);
|
||||
|
||||
// 循环调用将数据传出去
|
||||
for (IMoGoTokenCallback tokenCallback : mTokenCallbacks) {
|
||||
tokenCallback.onTokenGot(token, sn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -210,15 +210,11 @@ public class SocketManager implements IMogoCloudSocketManager {
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
mListeners.clear();
|
||||
mAckListeners.clear();
|
||||
if (cloudClientConfig.isThirdLogin()) {
|
||||
ThirdSocketManager.getInstance().release();
|
||||
} else {
|
||||
InternalSocketManager.getInstance().release();
|
||||
}
|
||||
cloudClientConfig = null;
|
||||
mInstance = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public class ThirdSocketManager implements Callback {
|
||||
.setAuthPubKey(cloudClientConfig.getAuthPubKey())
|
||||
.setDebug(cloudClientConfig.isShowDebugLog());
|
||||
SocketClient.getInstance().registerSocketCallback(this);
|
||||
// SocketClient.getInstance().registerSocketConnCallback(this);
|
||||
SocketClient.getInstance().start(context);
|
||||
}
|
||||
|
||||
@@ -75,7 +74,6 @@ public class ThirdSocketManager implements Callback {
|
||||
boolean ack,
|
||||
long msgId) {
|
||||
SocketClient.getInstance().sendData(SOCKET_CHANNEL_ID, MogoCommon.Product.mogoBussiness.getNumber(), payload, headerType, ack, msgId);
|
||||
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
|
||||
@@ -30,22 +30,22 @@ PASSWORD=xintai2018
|
||||
RELEASE=true
|
||||
# AI CLOUD 云平台
|
||||
# 工具类
|
||||
MOGO_UTILS_VERSION=1.1.27
|
||||
MOGO_UTILS_VERSION=1.1.33
|
||||
# 网络请求
|
||||
MOGO_NETWORK_VERSION=1.1.27
|
||||
MOGO_NETWORK_VERSION=1.1.33
|
||||
# 网络DNS
|
||||
MOGO_HTTPDNS_VERSION=1.1.27
|
||||
MOGO_HTTPDNS_VERSION=1.1.33
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.1.27
|
||||
MOGO_PASSPORT_VERSION=1.1.33
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.1.27
|
||||
MOGO_SOCKET_VERSION=1.1.33
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.1.27
|
||||
MOGO_REALTIME_VERSION=1.1.33
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.1.27
|
||||
MOGO_TANLU_VERSION=1.1.33
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.1.27
|
||||
MOGO_LIVE_VERSION=1.1.33
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.1.27
|
||||
MOGO_TRAFFICLIVE_VERSION=1.1.33
|
||||
# 定位服务
|
||||
MOGO_LOCATION_VERSION=1.1.27
|
||||
MOGO_LOCATION_VERSION=1.1.33
|
||||
|
||||
Reference in New Issue
Block a user