merge
This commit is contained in:
@@ -15,14 +15,12 @@ ext {
|
|||||||
androidxappcompat : "androidx.appcompat:appcompat:1.3.1",
|
androidxappcompat : "androidx.appcompat:appcompat:1.3.1",
|
||||||
androidxconstraintlayout : "androidx.constraintlayout:constraintlayout:2.1.0",
|
androidxconstraintlayout : "androidx.constraintlayout:constraintlayout:2.1.0",
|
||||||
boostmultidex : "com.bytedance.boost_multidex:boost_multidex:1.0.1",
|
boostmultidex : "com.bytedance.boost_multidex:boost_multidex:1.0.1",
|
||||||
|
// logger
|
||||||
|
logger : "com.elegant.logger:logger:1.0.5",
|
||||||
// flexbox
|
// flexbox
|
||||||
flexbox : 'com.google.android:flexbox:2.0.1',
|
flexbox : 'com.google.android:flexbox:2.0.1',
|
||||||
// 测试
|
// 测试
|
||||||
junit : "junit:junit:4.12",
|
junit : "junit:junit:4.12",
|
||||||
// 地图
|
|
||||||
amapnavi3dmap : "com.amap.api:navi-3dmap:7.2.0_3dmap7.2.0",
|
|
||||||
amapsearch : "com.amap.api:search:7.1.0",
|
|
||||||
amaplocation : "com.amap.api:location:5.2.0",
|
|
||||||
// json 转换
|
// json 转换
|
||||||
gson : "com.google.code.gson:gson:2.8.4",
|
gson : "com.google.code.gson:gson:2.8.4",
|
||||||
// 内存泄漏检测
|
// 内存泄漏检测
|
||||||
@@ -63,7 +61,6 @@ ext {
|
|||||||
// 直播SDK
|
// 直播SDK
|
||||||
live_sdk_zego : "im.zego:express-video:2.2.0",
|
live_sdk_zego : "im.zego:express-video:2.2.0",
|
||||||
|
|
||||||
aspectj : "org.aspectj:aspectjrt:1.8.9",
|
|
||||||
adasapi : "com.zhidao.autopilot.support:adas:1.0.6.6",
|
adasapi : "com.zhidao.autopilot.support:adas:1.0.6.6",
|
||||||
adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.1.5.2",
|
adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.1.5.2",
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||||
|
implementation rootProject.ext.dependencies.logger
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
@@ -14,7 +14,7 @@ import com.mogo.cloud.httpdns.util.NetWorkUtil
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. 网络状态发生变化时候,重置15min轮询,并查询一次
|
* 1. 网络状态发生变化时候,重置轮询,并查询一次
|
||||||
*
|
*
|
||||||
* @author tongchenfei
|
* @author tongchenfei
|
||||||
*/
|
*/
|
||||||
@@ -43,12 +43,10 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
|||||||
private var httpDnsCache: HttpDnsSimpleLocation? = null
|
private var httpDnsCache: HttpDnsSimpleLocation? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
L.isDebug = builder.showDebugLog()
|
|
||||||
defaultUrl = builder.getDefaultUrl()
|
defaultUrl = builder.getDefaultUrl()
|
||||||
L.d(TAG, "init===")
|
L.d(TAG, "init===")
|
||||||
checkParams()
|
checkParams()
|
||||||
isInit = true
|
isInit = true
|
||||||
L.d(TAG, "params available, prepare to start check net status")
|
|
||||||
workThread.start()
|
workThread.start()
|
||||||
handler = Handler(workThread.looper, this)
|
handler = Handler(workThread.looper, this)
|
||||||
apiManager = ApiManager(builder.getSn()!!, builder.getEnv(), builder.getAppKey())
|
apiManager = ApiManager(builder.getSn()!!, builder.getEnv(), builder.getAppKey())
|
||||||
@@ -68,10 +66,9 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
|||||||
private fun getHttpDnsAddressFromNet() {
|
private fun getHttpDnsAddressFromNet() {
|
||||||
val nAddress = apiManager.requestHttpDns(builder.getCurrentLocation()!!)
|
val nAddress = apiManager.requestHttpDns(builder.getCurrentLocation()!!)
|
||||||
if (addressChangedListener == null) {
|
if (addressChangedListener == null) {
|
||||||
L.d(TAG, "addressChangeList is null")
|
return
|
||||||
}
|
}
|
||||||
if (nAddress == null || nAddress.isEmpty()) {
|
if (nAddress == null || nAddress.isEmpty()) {
|
||||||
L.e(TAG, "getHttpDnsAddressFromNet nAddress result is null or empty ")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (addressMap == null) {
|
if (addressMap == null) {
|
||||||
@@ -90,10 +87,8 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun syncGetHttpDns(host: String, type: Int, useCache: Boolean): String? {
|
override fun syncGetHttpDns(host: String, type: Int, useCache: Boolean): String? {
|
||||||
L.d(TAG, "syncGetHttpDns $type-$host")
|
|
||||||
return if (useCache) {
|
return if (useCache) {
|
||||||
val address: String? = getHttpDnsCachedAddress(type, host)
|
getHttpDnsCachedAddress(type, host)
|
||||||
address ?: getHttpDnsAddress(type, host)
|
|
||||||
} else {
|
} else {
|
||||||
getHttpDnsAddress(type, host)
|
getHttpDnsAddress(type, host)
|
||||||
}
|
}
|
||||||
@@ -118,15 +113,13 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
L.d(TAG, "not init over")
|
|
||||||
throw IllegalStateException("Http dns not init")
|
throw IllegalStateException("Http dns not init")
|
||||||
}
|
}
|
||||||
return defaultUrl ?: host
|
return defaultUrl ?: host
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getHttpDnsCachedAddress(type: Int, _host: String): String? {
|
override fun getHttpDnsCachedAddress(type: Int, _host: String): String {
|
||||||
val host = _host.toLowerCase(Locale.getDefault())
|
val host = _host.toLowerCase(Locale.getDefault())
|
||||||
L.d(TAG, "getHttpDnsCachedAddress: $type-$host")
|
|
||||||
httpDnsCache?.let {
|
httpDnsCache?.let {
|
||||||
val currentLoc = builder.getCurrentLocation()?.getCurrentLocation()
|
val currentLoc = builder.getCurrentLocation()?.getCurrentLocation()
|
||||||
currentLoc?.let { cur ->
|
currentLoc?.let { cur ->
|
||||||
@@ -139,7 +132,7 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
|||||||
) {
|
) {
|
||||||
L.d(
|
L.d(
|
||||||
TAG,
|
TAG,
|
||||||
"getHttpDnsCachedAddress httpDnsCache: ${httpDnsCache.toString()} , currentLoc: $currentLoc"
|
"getHttpDnsCachedAddress : $type-$host , httpDnsCache: ${httpDnsCache.toString()} , currentLoc: $currentLoc"
|
||||||
)
|
)
|
||||||
httpDnsCache = currentLoc
|
httpDnsCache = currentLoc
|
||||||
getHttpDnsAddress(type, _host)
|
getHttpDnsAddress(type, _host)
|
||||||
@@ -156,13 +149,10 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
|||||||
|
|
||||||
override fun handleMessage(msg: Message): Boolean {
|
override fun handleMessage(msg: Message): Boolean {
|
||||||
if (msg.what == MSG_REQUEST_IP_PORT) {
|
if (msg.what == MSG_REQUEST_IP_PORT) {
|
||||||
L.d(TAG, "http dns loop check")
|
|
||||||
if (isInit) {
|
if (isInit) {
|
||||||
// 网络接口请求
|
// 网络接口请求
|
||||||
getHttpDnsAddressFromNet()
|
getHttpDnsAddressFromNet()
|
||||||
handler.sendEmptyMessageDelayed(MSG_REQUEST_IP_PORT, builder.getLoopCheckDelay())
|
handler.sendEmptyMessageDelayed(MSG_REQUEST_IP_PORT, builder.getLoopCheckDelay())
|
||||||
} else {
|
|
||||||
L.d(TAG, "not init over")
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -187,23 +177,17 @@ internal class HttpDnsHelper(private val builder: MogoHttpDnsConfig) : Handler.C
|
|||||||
diff[key] = null
|
diff[key] = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i in diff.keys) {
|
|
||||||
L.d(TAG, "diff key: $i")
|
|
||||||
}
|
|
||||||
return diff
|
return diff
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkParams(): Boolean {
|
private fun checkParams(): Boolean {
|
||||||
if (builder.getContext() == null) {
|
if (builder.getContext() == null) {
|
||||||
L.e(TAG, "no context")
|
|
||||||
throw IllegalArgumentException("can not find context in builder")
|
throw IllegalArgumentException("can not find context in builder")
|
||||||
}
|
}
|
||||||
if (builder.getSn() == null) {
|
if (builder.getSn() == null) {
|
||||||
L.e(TAG, "no sn")
|
|
||||||
throw IllegalArgumentException("can not find sn in builder")
|
throw IllegalArgumentException("can not find sn in builder")
|
||||||
}
|
}
|
||||||
if (builder.getCurrentLocation() == null) {
|
if (builder.getCurrentLocation() == null) {
|
||||||
L.e(TAG, "no current location")
|
|
||||||
throw IllegalArgumentException("can not find currentLocation in builder")
|
throw IllegalArgumentException("can not find currentLocation in builder")
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
package com.mogo.cloud.httpdns.util
|
package com.mogo.cloud.httpdns.util
|
||||||
|
|
||||||
import android.util.Log
|
import com.elegant.log.simplelog.Logger
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 简单实现日志工具类
|
* 简单实现日志工具类
|
||||||
*
|
|
||||||
* @author tongchenfei
|
|
||||||
*/
|
*/
|
||||||
object L {
|
object L {
|
||||||
var isDebug = true
|
|
||||||
fun d(tag: String, msg: String) {
|
fun d(tag: String, msg: String) {
|
||||||
if (isDebug) {
|
Logger.d(tag, msg)
|
||||||
Log.d(tag, msg)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun e(tag: String, msg: String) {
|
fun e(tag: String, msg: String) {
|
||||||
Log.e(tag, msg)
|
Logger.e(tag, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,6 @@ import android.content.Intent
|
|||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
|
|
||||||
private const val TAG = "NetWorkUtil"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网络状态工具类
|
* 网络状态工具类
|
||||||
* 监听和获取网络状态
|
* 监听和获取网络状态
|
||||||
@@ -35,11 +33,9 @@ class NetWorkUtil {
|
|||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
connectivityManager?.apply {
|
connectivityManager?.apply {
|
||||||
if (activeNetworkInfo == null) {
|
if (activeNetworkInfo == null) {
|
||||||
L.d(TAG, "activityNetworkInfo is null")
|
|
||||||
statusCallback?.invoke(false)
|
statusCallback?.invoke(false)
|
||||||
} else {
|
} else {
|
||||||
if (activeNetworkInfo!!.type == -1) {
|
if (activeNetworkInfo!!.type == -1) {
|
||||||
L.d(TAG, "activityNetworkInfo.type == -1")
|
|
||||||
statusCallback?.invoke(false)
|
statusCallback?.invoke(false)
|
||||||
} else {
|
} else {
|
||||||
//L.d(TAG, "activityNetworkInfo.type: ${activeNetworkInfo!!.type}")
|
//L.d(TAG, "activityNetworkInfo.type: ${activeNetworkInfo!!.type}")
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import static im.zego.zegoexpress.constants.ZegoRoomState.DISCONNECTED;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.view.TextureView;
|
import android.view.TextureView;
|
||||||
|
|
||||||
@@ -145,7 +144,7 @@ public class MoGoLiveManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private MoGoLiveManager() {
|
private MoGoLiveManager() {
|
||||||
Log.i(TAG, "初始化 MoGoLiveManager");
|
Logger.i(TAG, "初始化 MoGoLiveManager");
|
||||||
mLiveStatusModel = new LiveStatusModel();
|
mLiveStatusModel = new LiveStatusModel();
|
||||||
|
|
||||||
zeGoRoomConfig = new ZegoRoomConfig();
|
zeGoRoomConfig = new ZegoRoomConfig();
|
||||||
@@ -187,7 +186,7 @@ public class MoGoLiveManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onDebugError(int errorCode, String funcName, String info) {
|
public void onDebugError(int errorCode, String funcName, String info) {
|
||||||
super.onDebugError(errorCode, funcName, info);
|
super.onDebugError(errorCode, funcName, info);
|
||||||
Log.i(TAG, "调试错误信息回调 onDebugError errorCode : " + errorCode);
|
Logger.i(TAG, "调试错误信息回调 onDebugError errorCode : " + errorCode);
|
||||||
for (ILiveProgressListener iLiveProgressListener : mProgressListener) {
|
for (ILiveProgressListener iLiveProgressListener : mProgressListener) {
|
||||||
iLiveProgressListener.onDebugError(errorCode, funcName, info);
|
iLiveProgressListener.onDebugError(errorCode, funcName, info);
|
||||||
}
|
}
|
||||||
@@ -202,7 +201,7 @@ public class MoGoLiveManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onEngineStateUpdate(ZegoEngineState state) {
|
public void onEngineStateUpdate(ZegoEngineState state) {
|
||||||
super.onEngineStateUpdate(state);
|
super.onEngineStateUpdate(state);
|
||||||
Log.i(TAG, "音视频引擎状态更新回调 onEngineStateUpdate state : " + state.name());
|
Logger.i(TAG, "音视频引擎状态更新回调 onEngineStateUpdate state : " + state.name());
|
||||||
if (state == ZegoEngineState.START) {
|
if (state == ZegoEngineState.START) {
|
||||||
for (ILiveProgressListener iLiveProgressListener : mProgressListener) {
|
for (ILiveProgressListener iLiveProgressListener : mProgressListener) {
|
||||||
iLiveProgressListener.onEngineStart();
|
iLiveProgressListener.onEngineStart();
|
||||||
@@ -220,7 +219,7 @@ public class MoGoLiveManager {
|
|||||||
super.onRoomStateUpdate(roomID, state, errorCode, extendedData);
|
super.onRoomStateUpdate(roomID, state, errorCode, extendedData);
|
||||||
// 这里回调的是当前用户的房间状态
|
// 这里回调的是当前用户的房间状态
|
||||||
if (mLiveStatusModel.getCurrentRoomId().equals(roomID)) {
|
if (mLiveStatusModel.getCurrentRoomId().equals(roomID)) {
|
||||||
Log.i(TAG, "房间状态变化通知 onRoomStateUpdate currentRoomId : " + roomID +
|
Logger.i(TAG, "房间状态变化通知 onRoomStateUpdate currentRoomId : " + roomID +
|
||||||
" state:" + state +
|
" state:" + state +
|
||||||
" errorCode:" + errorCode +
|
" errorCode:" + errorCode +
|
||||||
" extendedData:" + extendedData.toString());
|
" extendedData:" + extendedData.toString());
|
||||||
@@ -265,7 +264,7 @@ public class MoGoLiveManager {
|
|||||||
}
|
}
|
||||||
// 这里回调的是登录的他人房间的状态
|
// 这里回调的是登录的他人房间的状态
|
||||||
if (mLiveStatusModel.getMultiRoomId().equals(roomID)) {
|
if (mLiveStatusModel.getMultiRoomId().equals(roomID)) {
|
||||||
Log.i(TAG, "这里回调的是登录的他人房间的状态 onRoomStateUpdate multiRoomId : " + roomID +
|
Logger.i(TAG, "这里回调的是登录的他人房间的状态 onRoomStateUpdate multiRoomId : " + roomID +
|
||||||
" state:" + state +
|
" state:" + state +
|
||||||
" errorCode:" + errorCode +
|
" errorCode:" + errorCode +
|
||||||
" extendedData:" + extendedData.toString());
|
" extendedData:" + extendedData.toString());
|
||||||
@@ -299,7 +298,7 @@ public class MoGoLiveManager {
|
|||||||
if (count > 2) {
|
if (count > 2) {
|
||||||
PushService.startService(mApplication, PushService.ACTION_START_RTMP_PUSH);
|
PushService.startService(mApplication, PushService.ACTION_START_RTMP_PUSH);
|
||||||
}
|
}
|
||||||
Log.i(TAG, "房间内当前在线用户数量回调 onRoomOnlineUserCountUpdate roomID : " + roomID +
|
Logger.i(TAG, "房间内当前在线用户数量回调 onRoomOnlineUserCountUpdate roomID : " + roomID +
|
||||||
" , online user number : " + mLiveStatusModel.getOnlineNumber());
|
" , online user number : " + mLiveStatusModel.getOnlineNumber());
|
||||||
for (ILiveRoomPersonListener iLiveRoomPersonListener : mRoomPersonListener) {
|
for (ILiveRoomPersonListener iLiveRoomPersonListener : mRoomPersonListener) {
|
||||||
if (iLiveRoomPersonListener != null) {
|
if (iLiveRoomPersonListener != null) {
|
||||||
@@ -322,7 +321,7 @@ public class MoGoLiveManager {
|
|||||||
mLiveStatusModel.setOnlineNumber(mLiveStatusModel.getOnlineNumber() - userList.size());
|
mLiveStatusModel.setOnlineNumber(mLiveStatusModel.getOnlineNumber() - userList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "房间内其他用户增加或减少的通知回调 onRoomUserUpdate roomId : " + roomID +
|
Logger.i(TAG, "房间内其他用户增加或减少的通知回调 onRoomUserUpdate roomId : " + roomID +
|
||||||
" , updateType : " + updateType.name() +
|
" , updateType : " + updateType.name() +
|
||||||
" , online user number : " + mLiveStatusModel.getOnlineNumber());
|
" , online user number : " + mLiveStatusModel.getOnlineNumber());
|
||||||
for (ILiveRoomPersonListener iLiveRoomPersonListener : mRoomPersonListener) {
|
for (ILiveRoomPersonListener iLiveRoomPersonListener : mRoomPersonListener) {
|
||||||
@@ -343,7 +342,7 @@ public class MoGoLiveManager {
|
|||||||
if (mLiveStatusModel.getCurrentStreamId().equals(streamID)) {
|
if (mLiveStatusModel.getCurrentStreamId().equals(streamID)) {
|
||||||
// 判断不是非推流状态则为推流
|
// 判断不是非推流状态则为推流
|
||||||
mLiveStatusModel.setPushing(state != ZegoPublisherState.NO_PUBLISH);
|
mLiveStatusModel.setPushing(state != ZegoPublisherState.NO_PUBLISH);
|
||||||
Log.i(TAG, "推流状态回调 onPublisherStateUpdate streamID : " + streamID +
|
Logger.i(TAG, "推流状态回调 onPublisherStateUpdate streamID : " + streamID +
|
||||||
" , isPushing : " + mLiveStatusModel.isPushing() +
|
" , isPushing : " + mLiveStatusModel.isPushing() +
|
||||||
" , state : " + state.name() +
|
" , state : " + state.name() +
|
||||||
" , errorCode : " + errorCode +
|
" , errorCode : " + errorCode +
|
||||||
@@ -374,7 +373,7 @@ public class MoGoLiveManager {
|
|||||||
if (mMediaPlayerStateListener != null && errorCode != 0) {
|
if (mMediaPlayerStateListener != null && errorCode != 0) {
|
||||||
mMediaPlayerStateListener.onPullStreamError(errorCode);
|
mMediaPlayerStateListener.onPullStreamError(errorCode);
|
||||||
}
|
}
|
||||||
Log.i(TAG, " 拉流状态变更回调 onPlayerStateUpdate streamId : " + streamID +
|
Logger.i(TAG, " 拉流状态变更回调 onPlayerStateUpdate streamId : " + streamID +
|
||||||
" , isPlaying : " + mLiveStatusModel.isPlaying() +
|
" , isPlaying : " + mLiveStatusModel.isPlaying() +
|
||||||
" , state : " + state.name() +
|
" , state : " + state.name() +
|
||||||
" , errorCode : " + errorCode +
|
" , errorCode : " + errorCode +
|
||||||
@@ -392,19 +391,19 @@ public class MoGoLiveManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onPlayerRecvAudioFirstFrame(String streamID) {
|
public void onPlayerRecvAudioFirstFrame(String streamID) {
|
||||||
super.onPlayerRecvAudioFirstFrame(streamID);
|
super.onPlayerRecvAudioFirstFrame(streamID);
|
||||||
Log.d(TAG, "onPlayerRecvAudioFirstFrame");
|
Logger.d(TAG, "onPlayerRecvAudioFirstFrame");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerRenderVideoFirstFrame(String streamID) {
|
public void onPlayerRenderVideoFirstFrame(String streamID) {
|
||||||
super.onPlayerRenderVideoFirstFrame(streamID);
|
super.onPlayerRenderVideoFirstFrame(streamID);
|
||||||
Log.d(TAG, "onPlayerRenderVideoFirstFrame");
|
Logger.d(TAG, "onPlayerRenderVideoFirstFrame");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerRecvVideoFirstFrame(String streamID) {
|
public void onPlayerRecvVideoFirstFrame(String streamID) {
|
||||||
super.onPlayerRecvVideoFirstFrame(streamID);
|
super.onPlayerRecvVideoFirstFrame(streamID);
|
||||||
Log.d(TAG, "onPlayerRecvVideoFirstFrame");
|
Logger.d(TAG, "onPlayerRecvVideoFirstFrame");
|
||||||
if (mMediaPlayerStateListener != null) {
|
if (mMediaPlayerStateListener != null) {
|
||||||
mMediaPlayerStateListener.onVideoFirstFrame();
|
mMediaPlayerStateListener.onVideoFirstFrame();
|
||||||
}
|
}
|
||||||
@@ -414,7 +413,7 @@ public class MoGoLiveManager {
|
|||||||
public void onRemoteCameraStateUpdate(String streamID, ZegoRemoteDeviceState state) {
|
public void onRemoteCameraStateUpdate(String streamID, ZegoRemoteDeviceState state) {
|
||||||
super.onRemoteCameraStateUpdate(streamID, state);
|
super.onRemoteCameraStateUpdate(streamID, state);
|
||||||
if (state != OPEN) {
|
if (state != OPEN) {
|
||||||
Log.e(TAG, "onRemoteCameraStateUpdate:" + state);
|
Logger.e(TAG, "onRemoteCameraStateUpdate:" + state);
|
||||||
if (mMediaPlayerStateListener != null) {
|
if (mMediaPlayerStateListener != null) {
|
||||||
mMediaPlayerStateListener.remoteDeviceError();
|
mMediaPlayerStateListener.remoteDeviceError();
|
||||||
}
|
}
|
||||||
@@ -424,7 +423,7 @@ public class MoGoLiveManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onDeviceError(int errorCode, String deviceName) {
|
public void onDeviceError(int errorCode, String deviceName) {
|
||||||
super.onDeviceError(errorCode, deviceName);
|
super.onDeviceError(errorCode, deviceName);
|
||||||
Log.e(TAG, "onDeviceError:" + errorCode);
|
Logger.e(TAG, "onDeviceError:" + errorCode);
|
||||||
if (mMediaPlayerStateListener != null && errorCode != 0) {
|
if (mMediaPlayerStateListener != null && errorCode != 0) {
|
||||||
mMediaPlayerStateListener.onDeviceError(errorCode);
|
mMediaPlayerStateListener.onDeviceError(errorCode);
|
||||||
}
|
}
|
||||||
@@ -489,7 +488,7 @@ public class MoGoLiveManager {
|
|||||||
* 初始化自定义采集
|
* 初始化自定义采集
|
||||||
*/
|
*/
|
||||||
public void initExpressEngine() {
|
public void initExpressEngine() {
|
||||||
Log.i(TAG, "initCustomVideoCapture 初始化引擎");
|
Logger.i(TAG, "initCustomVideoCapture 初始化引擎");
|
||||||
mLiveStatusModel.setExpressEngineCanUse(true);
|
mLiveStatusModel.setExpressEngineCanUse(true);
|
||||||
// 创建 enging 对象, appID, appSign 为开发者在 ZEGO 管理控制台申请的凭证信息,
|
// 创建 enging 对象, appID, appSign 为开发者在 ZEGO 管理控制台申请的凭证信息,
|
||||||
// 未上线的开发者 isTestEnvironment 为 true, application 为安卓应用的上下文
|
// 未上线的开发者 isTestEnvironment 为 true, application 为安卓应用的上下文
|
||||||
@@ -564,14 +563,14 @@ public class MoGoLiveManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onStart(ZegoPublishChannel channel) {
|
public void onStart(ZegoPublishChannel channel) {
|
||||||
super.onStart(channel);
|
super.onStart(channel);
|
||||||
Log.i(TAG, "SDK 通知将要开始采集视频帧 setCustomVideoCaptureHandler onStart");
|
Logger.i(TAG, "SDK 通知将要开始采集视频帧 setCustomVideoCaptureHandler onStart");
|
||||||
mLiveStatusModel.setCaptureStatus(true);
|
mLiveStatusModel.setCaptureStatus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop(ZegoPublishChannel channel) {
|
public void onStop(ZegoPublishChannel channel) {
|
||||||
super.onStop(channel);
|
super.onStop(channel);
|
||||||
Log.i(TAG, "SDK 通知将要停止采集视频帧 setCustomVideoCaptureHandler onStop");
|
Logger.i(TAG, "SDK 通知将要停止采集视频帧 setCustomVideoCaptureHandler onStop");
|
||||||
mLiveStatusModel.setCaptureStatus(false);
|
mLiveStatusModel.setCaptureStatus(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -592,7 +591,7 @@ public class MoGoLiveManager {
|
|||||||
}
|
}
|
||||||
mLiveStatusModel.setCurrentRoomId(ROOM_ID_PREFIX + userId);
|
mLiveStatusModel.setCurrentRoomId(ROOM_ID_PREFIX + userId);
|
||||||
mLiveStatusModel.setCurrentStreamId(STREAM_ID_PREFIX + userId);
|
mLiveStatusModel.setCurrentStreamId(STREAM_ID_PREFIX + userId);
|
||||||
Log.i(TAG,
|
Logger.i(TAG,
|
||||||
"尝试进入自己房间 loginRoom userId : " + userId
|
"尝试进入自己房间 loginRoom userId : " + userId
|
||||||
+ " currentRoomId:" + mLiveStatusModel.getCurrentRoomId()
|
+ " currentRoomId:" + mLiveStatusModel.getCurrentRoomId()
|
||||||
+ " currentStreamId:" + mLiveStatusModel.getCurrentStreamId());
|
+ " currentStreamId:" + mLiveStatusModel.getCurrentStreamId());
|
||||||
@@ -606,20 +605,20 @@ public class MoGoLiveManager {
|
|||||||
* 退出自己房间
|
* 退出自己房间
|
||||||
*/
|
*/
|
||||||
public synchronized void logoutCurrentRoom() {
|
public synchronized void logoutCurrentRoom() {
|
||||||
Log.i(TAG, "尝试退出自己房间 logoutRoom : " + mLiveStatusModel.getCurrentRoomId());
|
Logger.i(TAG, "尝试退出自己房间 logoutRoom : " + mLiveStatusModel.getCurrentRoomId());
|
||||||
if (mExpressEngine != null) {
|
if (mExpressEngine != null) {
|
||||||
if (!mLiveStatusModel.isLoginCurrentRoom()) {
|
if (!mLiveStatusModel.isLoginCurrentRoom()) {
|
||||||
Log.w(TAG, "还未登录自己房间");
|
Logger.w(TAG, "还未登录自己房间");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mLiveStatusModel.isPlaying()) {
|
if (mLiveStatusModel.isPlaying()) {
|
||||||
Log.w(TAG, "处于播放中,不可退出房间");
|
Logger.w(TAG, "处于播放中,不可退出房间");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.i(TAG, "执行退出房间操作");
|
Logger.i(TAG, "执行退出房间操作");
|
||||||
mExpressEngine.logoutRoom(mLiveStatusModel.getCurrentRoomId());
|
mExpressEngine.logoutRoom(mLiveStatusModel.getCurrentRoomId());
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "ZeGo 引擎未初始化");
|
Logger.w(TAG, "ZeGo 引擎未初始化");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,14 +633,14 @@ public class MoGoLiveManager {
|
|||||||
}
|
}
|
||||||
mLiveStatusModel.setMultiRoomId(ROOM_ID_PREFIX + otherRoomId);
|
mLiveStatusModel.setMultiRoomId(ROOM_ID_PREFIX + otherRoomId);
|
||||||
mLiveStatusModel.setMultiStreamId(STREAM_ID_PREFIX + otherRoomId);
|
mLiveStatusModel.setMultiStreamId(STREAM_ID_PREFIX + otherRoomId);
|
||||||
Log.i(TAG,
|
Logger.i(TAG,
|
||||||
"尝试进入多房间 loginMultiRoom multiRoomId : " + mLiveStatusModel.getMultiRoomId()
|
"尝试进入多房间 loginMultiRoom multiRoomId : " + mLiveStatusModel.getMultiRoomId()
|
||||||
+ " currentStreamId : " + mLiveStatusModel.getMultiStreamId());
|
+ " currentStreamId : " + mLiveStatusModel.getMultiStreamId());
|
||||||
// if (!mLiveStatusModel.isLoginMultiRoom()) {
|
// if (!mLiveStatusModel.isLoginMultiRoom()) {
|
||||||
Log.i(TAG, "执行登录多房间");
|
Logger.i(TAG, "执行登录多房间");
|
||||||
mExpressEngine.loginRoom(mLiveStatusModel.getMultiRoomId(), zegoUserCurrent, zeGoRoomConfig);
|
mExpressEngine.loginRoom(mLiveStatusModel.getMultiRoomId(), zegoUserCurrent, zeGoRoomConfig);
|
||||||
// } else {
|
// } else {
|
||||||
// Log.w(TAG, "已经登录了多房间");
|
// Logger.w(TAG, "已经登录了多房间");
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,16 +648,16 @@ public class MoGoLiveManager {
|
|||||||
* 退出多房间
|
* 退出多房间
|
||||||
*/
|
*/
|
||||||
public synchronized void logoutMultiRoom(String sn) {
|
public synchronized void logoutMultiRoom(String sn) {
|
||||||
Log.i(TAG, "尝试退出多房间 logoutMultiRoom multiRoomId : " + mLiveStatusModel.getMultiRoomId());
|
Logger.i(TAG, "尝试退出多房间 logoutMultiRoom multiRoomId : " + mLiveStatusModel.getMultiRoomId());
|
||||||
if (mExpressEngine != null) {
|
if (mExpressEngine != null) {
|
||||||
// if (mLiveStatusModel.isLoginMultiRoom()) {
|
// if (mLiveStatusModel.isLoginMultiRoom()) {
|
||||||
Log.i(TAG, "执行退出多房间");
|
Logger.i(TAG, "执行退出多房间");
|
||||||
mExpressEngine.logoutRoom(ROOM_ID_PREFIX + sn);
|
mExpressEngine.logoutRoom(ROOM_ID_PREFIX + sn);
|
||||||
// } else {
|
// } else {
|
||||||
// Log.w(TAG, "还未登录多房间");
|
// Logger.w(TAG, "还未登录多房间");
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "ZeGo 引擎未初始化");
|
Logger.w(TAG, "ZeGo 引擎未初始化");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,7 +665,7 @@ public class MoGoLiveManager {
|
|||||||
* 开始推流到ZeGo
|
* 开始推流到ZeGo
|
||||||
*/
|
*/
|
||||||
public void startPublish() {
|
public void startPublish() {
|
||||||
Log.i(TAG, "开始推流到ZeGo startPublish currentStreamId : " + mLiveStatusModel.getCurrentStreamId());
|
Logger.i(TAG, "开始推流到ZeGo startPublish currentStreamId : " + mLiveStatusModel.getCurrentStreamId());
|
||||||
ZegoPublisherConfig config = new ZegoPublisherConfig();
|
ZegoPublisherConfig config = new ZegoPublisherConfig();
|
||||||
config.roomID = mLiveStatusModel.getCurrentRoomId();
|
config.roomID = mLiveStatusModel.getCurrentRoomId();
|
||||||
mExpressEngine.startPublishingStream(mLiveStatusModel.getCurrentStreamId(), config, ZegoPublishChannel.MAIN);
|
mExpressEngine.startPublishingStream(mLiveStatusModel.getCurrentStreamId(), config, ZegoPublishChannel.MAIN);
|
||||||
@@ -695,7 +694,7 @@ public class MoGoLiveManager {
|
|||||||
* 停止推流到ZeGo
|
* 停止推流到ZeGo
|
||||||
*/
|
*/
|
||||||
public void stopPublish() {
|
public void stopPublish() {
|
||||||
Log.i(TAG, "停止推流到ZeGo stopPublish currentStreamId : " + mLiveStatusModel.getCurrentStreamId());
|
Logger.i(TAG, "停止推流到ZeGo stopPublish currentStreamId : " + mLiveStatusModel.getCurrentStreamId());
|
||||||
if (mExpressEngine == null) {
|
if (mExpressEngine == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -713,7 +712,7 @@ public class MoGoLiveManager {
|
|||||||
* @param surfaceView 渲染直播的视图
|
* @param surfaceView 渲染直播的视图
|
||||||
*/
|
*/
|
||||||
public void startLive(SurfaceView surfaceView) {
|
public void startLive(SurfaceView surfaceView) {
|
||||||
Log.i(TAG, "尝试开始播放直播 startLive multiStreamId : " + mLiveStatusModel.getMultiStreamId());
|
Logger.i(TAG, "尝试开始播放直播 startLive multiStreamId : " + mLiveStatusModel.getMultiStreamId());
|
||||||
if (!TextUtils.isEmpty(mLiveStatusModel.getMultiStreamId()) &&
|
if (!TextUtils.isEmpty(mLiveStatusModel.getMultiStreamId()) &&
|
||||||
mLiveStatusModel.getMultiStreamId().startsWith(STREAM_ID_PREFIX)) {
|
mLiveStatusModel.getMultiStreamId().startsWith(STREAM_ID_PREFIX)) {
|
||||||
ZegoCanvas zegoCanvas = new ZegoCanvas(surfaceView);
|
ZegoCanvas zegoCanvas = new ZegoCanvas(surfaceView);
|
||||||
@@ -724,12 +723,12 @@ public class MoGoLiveManager {
|
|||||||
|
|
||||||
mExpressEngine.startPlayingStream(mLiveStatusModel.getMultiStreamId(), zegoCanvas, config);
|
mExpressEngine.startPlayingStream(mLiveStatusModel.getMultiStreamId(), zegoCanvas, config);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "直播ID有误,请重试");
|
Logger.e(TAG, "直播ID有误,请重试");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startLive(TextureView textureView) {
|
public void startLive(TextureView textureView) {
|
||||||
Log.i(TAG, "尝试开始播放直播 startLive multiStreamId : " + mLiveStatusModel.getMultiStreamId());
|
Logger.i(TAG, "尝试开始播放直播 startLive multiStreamId : " + mLiveStatusModel.getMultiStreamId());
|
||||||
if (!TextUtils.isEmpty(mLiveStatusModel.getMultiStreamId()) &&
|
if (!TextUtils.isEmpty(mLiveStatusModel.getMultiStreamId()) &&
|
||||||
mLiveStatusModel.getMultiStreamId().startsWith(STREAM_ID_PREFIX)) {
|
mLiveStatusModel.getMultiStreamId().startsWith(STREAM_ID_PREFIX)) {
|
||||||
ZegoCanvas zegoCanvas = new ZegoCanvas(textureView);
|
ZegoCanvas zegoCanvas = new ZegoCanvas(textureView);
|
||||||
@@ -740,7 +739,7 @@ public class MoGoLiveManager {
|
|||||||
|
|
||||||
mExpressEngine.startPlayingStream(mLiveStatusModel.getMultiStreamId(), zegoCanvas, config);
|
mExpressEngine.startPlayingStream(mLiveStatusModel.getMultiStreamId(), zegoCanvas, config);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "直播ID有误,请重试");
|
Logger.e(TAG, "直播ID有误,请重试");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -748,9 +747,9 @@ public class MoGoLiveManager {
|
|||||||
* 停止播放直播
|
* 停止播放直播
|
||||||
*/
|
*/
|
||||||
public void stopLive(String sn) {
|
public void stopLive(String sn) {
|
||||||
Log.i(TAG, "尝试停止播放直播 stopLive multiStreamId : " + mLiveStatusModel.getMultiStreamId());
|
Logger.i(TAG, "尝试停止播放直播 stopLive multiStreamId : " + mLiveStatusModel.getMultiStreamId());
|
||||||
if (mExpressEngine == null) {
|
if (mExpressEngine == null) {
|
||||||
Log.w(TAG, "ZeGo 引擎未初始化");
|
Logger.w(TAG, "ZeGo 引擎未初始化");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 停止播放直播流
|
// 停止播放直播流
|
||||||
@@ -766,7 +765,7 @@ public class MoGoLiveManager {
|
|||||||
private void destroyEngine() {
|
private void destroyEngine() {
|
||||||
mExpressEngine.enableCustomVideoCapture(false, customVideoCaptureConfig, ZegoPublishChannel.MAIN);
|
mExpressEngine.enableCustomVideoCapture(false, customVideoCaptureConfig, ZegoPublishChannel.MAIN);
|
||||||
ZegoExpressEngine.destroyEngine(() -> {
|
ZegoExpressEngine.destroyEngine(() -> {
|
||||||
Log.i(TAG, "销毁ZeGo引擎");
|
Logger.i(TAG, "销毁ZeGo引擎");
|
||||||
mLiveStatusModel.setExpressEngineCanUse(false);
|
mLiveStatusModel.setExpressEngineCanUse(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.mogo.cloud.live.socket;
|
package com.mogo.cloud.live.socket;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
|
import com.elegant.log.simplelog.Logger;
|
||||||
import com.mogo.cloud.socket.IMogoCloudSocketMsgAckListener;
|
import com.mogo.cloud.socket.IMogoCloudSocketMsgAckListener;
|
||||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||||
import com.mogo.cloud.socket.SocketManager;
|
import com.mogo.cloud.socket.SocketManager;
|
||||||
@@ -43,7 +43,7 @@ public class SocketMsgUtils implements IMogoCloudSocketMsgAckListener {
|
|||||||
* 初始化长连接
|
* 初始化长连接
|
||||||
*/
|
*/
|
||||||
private void initSocket(IMogoCloudSocketOnMessageListener listener) {
|
private void initSocket(IMogoCloudSocketOnMessageListener listener) {
|
||||||
Log.i(TAG, "初始化长连接……");
|
Logger.i(TAG, "初始化长连接……");
|
||||||
mSocketManager = SocketManager.getInstance();
|
mSocketManager = SocketManager.getInstance();
|
||||||
mMessageListener = listener;
|
mMessageListener = listener;
|
||||||
mSocketManager.init(mContext);
|
mSocketManager.init(mContext);
|
||||||
@@ -69,6 +69,6 @@ public class SocketMsgUtils implements IMogoCloudSocketMsgAckListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAck(long msgId) {
|
public void onAck(long msgId) {
|
||||||
Log.i(TAG, "msgId=" + msgId);
|
Logger.i(TAG, "msgId=" + msgId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package com.mogo.cloud.passport;
|
package com.mogo.cloud.passport;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.Keep;
|
import androidx.annotation.Keep;
|
||||||
|
|
||||||
import com.elegant.log.simplelog.LogLevel;
|
|
||||||
import com.elegant.log.simplelog.Logger;
|
|
||||||
import com.mogo.cloud.httpdns.MogoHttpDnsClient;
|
import com.mogo.cloud.httpdns.MogoHttpDnsClient;
|
||||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||||
|
|
||||||
@@ -59,8 +56,9 @@ public class MoGoAiCloudClient {
|
|||||||
mAiCloudClientConfig = aiCloudClientConfig;
|
mAiCloudClientConfig = aiCloudClientConfig;
|
||||||
// 控制日志输出
|
// 控制日志输出
|
||||||
if (!mAiCloudClientConfig.isShowDebugLog()) {
|
if (!mAiCloudClientConfig.isShowDebugLog()) {
|
||||||
Logger.init(LogLevel.OFF);
|
|
||||||
// 关闭鉴权模块的日志
|
// 关闭鉴权模块的日志
|
||||||
|
com.zhidao.account.sdk.utils.Logger.init(false);
|
||||||
|
// 关闭所有SDK中的日志
|
||||||
com.elegant.log.simplelog.Logger.init(com.elegant.log.simplelog.LogLevel.OFF);
|
com.elegant.log.simplelog.Logger.init(com.elegant.log.simplelog.LogLevel.OFF);
|
||||||
}
|
}
|
||||||
// 刷新令牌
|
// 刷新令牌
|
||||||
@@ -77,23 +75,19 @@ public class MoGoAiCloudClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refreshToken() {
|
public void refreshToken() {
|
||||||
if (mAiCloudClientConfig.isShowDebugLog()) {
|
com.zhidao.account.sdk.utils.Logger.i(TAG, "═══════════════刷新Token═════════════");
|
||||||
Log.i(TAG, "═══════════════刷新Token═════════════");
|
|
||||||
}
|
|
||||||
|
|
||||||
PassportManager.getInstance().refreshToken(mContext, new IPassport() {
|
PassportManager.getInstance().refreshToken(mContext, new IPassport() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String token, String sn) {
|
public void onSuccess(String token, String sn) {
|
||||||
if (mAiCloudClientConfig.isShowDebugLog()) {
|
com.zhidao.account.sdk.utils.Logger.i(TAG, "═════════════════════════════════════");
|
||||||
Log.i(TAG, "═════════════════════════════════════");
|
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ PassportVersion:" + com.mogo.cloud.passport.BuildConfig.VERSION_NAME);
|
||||||
Log.i(TAG, "║ PassportVersion:" + com.mogo.cloud.passport.BuildConfig.VERSION_NAME);
|
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ HttpDnsVersion:" + com.mogo.cloud.httpdns.BuildConfig.VERSION_NAME);
|
||||||
Log.i(TAG, "║ HttpDnsVersion:" + com.mogo.cloud.httpdns.BuildConfig.VERSION_NAME);
|
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ ThirdLoginVersion:" + com.zhidao.thirdlogin.BuildConfig.VERSION_NAME);
|
||||||
Log.i(TAG, "║ ThirdLoginVersion:" + com.zhidao.thirdlogin.BuildConfig.VERSION_NAME);
|
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ MoGo鉴权成功 ");
|
||||||
Log.i(TAG, "║ MoGo鉴权成功 ");
|
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ SN:" + sn);
|
||||||
Log.i(TAG, "║ SN:" + sn);
|
com.zhidao.account.sdk.utils.Logger.i(TAG, "║ Token:" + token);
|
||||||
Log.i(TAG, "║ Token:" + token);
|
com.zhidao.account.sdk.utils.Logger.i(TAG, "═════════════════════════════════════");
|
||||||
Log.i(TAG, "═════════════════════════════════════");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 变量赋值
|
// 变量赋值
|
||||||
if (mAiCloudClientConfig != null) {
|
if (mAiCloudClientConfig != null) {
|
||||||
@@ -120,14 +114,13 @@ public class MoGoAiCloudClient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(int code, String msg) {
|
public void onError(int code, String msg) {
|
||||||
if (mAiCloudClientConfig.isShowDebugLog()) {
|
Toast.makeText(mContext, "MoGo鉴权失败", Toast.LENGTH_SHORT).show();
|
||||||
Toast.makeText(mContext, "MoGo鉴权失败", Toast.LENGTH_SHORT).show();
|
com.zhidao.account.sdk.utils.Logger.e(TAG, "═════════════════════════════════════");
|
||||||
Log.e(TAG, "═════════════════════════════════════");
|
com.zhidao.account.sdk.utils.Logger.e(TAG, "║ MoGo鉴权失败 ");
|
||||||
Log.e(TAG, "║ MoGo鉴权失败 ");
|
com.zhidao.account.sdk.utils.Logger.e(TAG, "║ ErrorCode:" + code);
|
||||||
Log.e(TAG, "║ ErrorCode:" + code);
|
com.zhidao.account.sdk.utils.Logger.e(TAG, "║ ErrorMessage:" + msg);
|
||||||
Log.e(TAG, "║ ErrorMessage:" + msg);
|
com.zhidao.account.sdk.utils.Logger.e(TAG, "═════════════════════════════════════");
|
||||||
Log.e(TAG, "═════════════════════════════════════");
|
|
||||||
}
|
|
||||||
// 变量赋值
|
// 变量赋值
|
||||||
if (mAiCloudClientConfig != null) {
|
if (mAiCloudClientConfig != null) {
|
||||||
mAiCloudClientConfig.setSn("");
|
mAiCloudClientConfig.setSn("");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.mogo.cloud.passport;
|
|||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.elegant.log.simplelog.LogLevel;
|
||||||
import com.elegant.log.simplelog.Logger;
|
import com.elegant.log.simplelog.Logger;
|
||||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||||
import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation;
|
import com.mogo.cloud.httpdns.listener.IHttpDnsCurrentLocation;
|
||||||
@@ -60,7 +61,7 @@ public class MoGoAiCloudClientConfig {
|
|||||||
/**
|
/**
|
||||||
* 是否打印日志
|
* 是否打印日志
|
||||||
*/
|
*/
|
||||||
private boolean isShowDebugLog = true;
|
private boolean isShowDebugLog = false;
|
||||||
/**
|
/**
|
||||||
* 是否Toast日志
|
* 是否Toast日志
|
||||||
*/
|
*/
|
||||||
@@ -285,6 +286,17 @@ public class MoGoAiCloudClientConfig {
|
|||||||
*/
|
*/
|
||||||
public void setShowDebugLog(boolean showDebugLog) {
|
public void setShowDebugLog(boolean showDebugLog) {
|
||||||
isShowDebugLog = showDebugLog;
|
isShowDebugLog = showDebugLog;
|
||||||
|
if (showDebugLog) {
|
||||||
|
// 打开鉴权模块的日志
|
||||||
|
com.zhidao.account.sdk.utils.Logger.init(true);
|
||||||
|
// 打开所有SDK中的日志
|
||||||
|
com.elegant.log.simplelog.Logger.init(LogLevel.DEBUG);
|
||||||
|
} else {
|
||||||
|
// 关闭鉴权模块的日志
|
||||||
|
com.zhidao.account.sdk.utils.Logger.init(false);
|
||||||
|
// 关闭所有SDK中的日志
|
||||||
|
com.elegant.log.simplelog.Logger.init(LogLevel.OFF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.mogo.cloud.passport.third;
|
package com.mogo.cloud.passport.third;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
|
import com.elegant.log.simplelog.Logger;
|
||||||
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
import com.mogo.cloud.httpdns.MogoHttpDnsConfig;
|
||||||
import com.mogo.cloud.passport.IPassport;
|
import com.mogo.cloud.passport.IPassport;
|
||||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||||
@@ -61,7 +61,7 @@ public class ThirdPassportManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (mAiCloudClientConfig.isShowDebugLog()) {
|
if (mAiCloudClientConfig.isShowDebugLog()) {
|
||||||
Log.w(TAG, "loginCallback:" + loginCallback);
|
Logger.w(TAG, "loginCallback:" + loginCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,10 +87,10 @@ public class ThirdPassportManager {
|
|||||||
thirdLoginParam,
|
thirdLoginParam,
|
||||||
loginCallback);
|
loginCallback);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "═════════════════════════════════════");
|
Logger.e(TAG, "═════════════════════════════════════");
|
||||||
Log.e(TAG, "║ MoGo 鉴权失败 ");
|
Logger.e(TAG, "║ MoGo 鉴权失败 ");
|
||||||
Log.e(TAG, "║ 请配置 MoGoAiCloudClientConfig 信息");
|
Logger.e(TAG, "║ 请配置 MoGoAiCloudClientConfig 信息");
|
||||||
Log.e(TAG, "═════════════════════════════════════");
|
Logger.e(TAG, "═════════════════════════════════════");
|
||||||
//todo 未来配置 errorCode设置回调错误码
|
//todo 未来配置 errorCode设置回调错误码
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ dependencies {
|
|||||||
api rootProject.ext.dependencies.spi
|
api rootProject.ext.dependencies.spi
|
||||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||||
api 'io.netty:netty-all:4.1.8.Final'
|
api 'io.netty:netty-all:4.1.8.Final'
|
||||||
|
implementation rootProject.ext.dependencies.logger
|
||||||
|
|
||||||
if (Boolean.valueOf(RELEASE)) {
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.mogo.telematic;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.nsd.NsdServiceInfo;
|
import android.net.nsd.NsdServiceInfo;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
|
import com.elegant.log.simplelog.Logger;
|
||||||
import com.mogo.telematic.client.NettyTcpClient;
|
import com.mogo.telematic.client.NettyTcpClient;
|
||||||
import com.mogo.telematic.client.NsdClient;
|
import com.mogo.telematic.client.NsdClient;
|
||||||
import com.mogo.telematic.client.listener.MessageStateListener;
|
import com.mogo.telematic.client.listener.MessageStateListener;
|
||||||
@@ -43,7 +43,7 @@ public class NSDNettyManager {
|
|||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NettyServerListener mDefaultServerListener = new NettyServerListener() {
|
private final NettyServerListener mDefaultServerListener = new NettyServerListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageResponseServer(Object msg, Channel channel) {
|
public void onMessageResponseServer(Object msg, Channel channel) {
|
||||||
@@ -129,7 +129,7 @@ public class NSDNettyManager {
|
|||||||
/**
|
/**
|
||||||
* 服务器端注册一个可供NSD探测到的网络 Ip 地址,便于给展示叫号机连接此socket
|
* 服务器端注册一个可供NSD探测到的网络 Ip 地址,便于给展示叫号机连接此socket
|
||||||
*/
|
*/
|
||||||
private Runnable mNsdServerRunnable = new Runnable() {
|
private final Runnable mNsdServerRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mNsdServer == null) {
|
if (mNsdServer == null) {
|
||||||
@@ -140,7 +140,7 @@ public class NSDNettyManager {
|
|||||||
mNsdServer.setRegisterState(new NSDServer.IRegisterState() {
|
mNsdServer.setRegisterState(new NSDServer.IRegisterState() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceRegistered(NsdServiceInfo serviceInfo) {
|
public void onServiceRegistered(NsdServiceInfo serviceInfo) {
|
||||||
Log.i(TAG, "已注册服务onServiceRegistered: " + serviceInfo.toString());
|
Logger.i(TAG, "已注册服务onServiceRegistered: " + serviceInfo.toString());
|
||||||
//已经注册可停止该服务
|
//已经注册可停止该服务
|
||||||
// nsdServer.stopNSDServer();
|
// nsdServer.stopNSDServer();
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ public class NSDNettyManager {
|
|||||||
public void onServerFound(NsdServiceInfo info, int port) {
|
public void onServerFound(NsdServiceInfo info, int port) {
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
String hostAddress = info.getHost().getHostAddress();
|
String hostAddress = info.getHost().getHostAddress();
|
||||||
Log.d(TAG, "NSD查询到指定服务器信息ip为:" + hostAddress + ",port为:" + port);
|
Logger.d(TAG, "NSD查询到指定服务器信息ip为:" + hostAddress + ",port为:" + port);
|
||||||
//获取到指定的地址,进行Netty的连接
|
//获取到指定的地址,进行Netty的连接
|
||||||
connectNettyServer(hostAddress, port, uuid, listener);
|
connectNettyServer(hostAddress, port, uuid, listener);
|
||||||
|
|
||||||
@@ -209,9 +209,9 @@ public class NSDNettyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void connectNettyServer(String serverAddress, int port, String sign, NettyClientListener listener) {
|
private void connectNettyServer(String serverAddress, int port, String sign, NettyClientListener listener) {
|
||||||
Log.d(TAG, "connectNettyServer");
|
Logger.d(TAG, "connectNettyServer");
|
||||||
if (serverAddress == null || serverAddress.length() == 0) {
|
if (serverAddress == null || serverAddress.length() == 0) {
|
||||||
Log.e(TAG, "Netty Server的ip不能为空!");
|
Logger.e(TAG, "Netty Server的ip不能为空!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mNettyTcpClient == null) {
|
if (mNettyTcpClient == null) {
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import android.net.nsd.NsdManager;
|
|||||||
import android.net.nsd.NsdServiceInfo;
|
import android.net.nsd.NsdServiceInfo;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.Log;
|
|
||||||
|
import com.elegant.log.simplelog.Logger;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -22,19 +23,19 @@ public class NsdClient {
|
|||||||
|
|
||||||
private NsdManager.DiscoveryListener mDiscoveryListener;
|
private NsdManager.DiscoveryListener mDiscoveryListener;
|
||||||
private NsdManager mNsdManager;
|
private NsdManager mNsdManager;
|
||||||
private Context mContext;
|
private final Context mContext;
|
||||||
private String mServiceName;
|
private final String mServiceName;
|
||||||
private IServerFound mIServerFound;
|
private final IServerFound mIServerFound;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用来存储解析后的网络对象列表,包含完整数据
|
* 用来存储解析后的网络对象列表,包含完整数据
|
||||||
*/
|
*/
|
||||||
private ArrayList<NsdServiceInfo> mNsdServiceInfoList = new ArrayList<>();
|
private final ArrayList<NsdServiceInfo> mNsdServiceInfoList = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 未解析前搜索到的
|
* 未解析前搜索到的
|
||||||
*/
|
*/
|
||||||
private ArrayList<NsdServiceInfo> mNsdServiceInfoListBefore = new ArrayList<>();
|
private final ArrayList<NsdServiceInfo> mNsdServiceInfoListBefore = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
private static final int MSG_RESOLVER = 1002;
|
private static final int MSG_RESOLVER = 1002;
|
||||||
@@ -67,23 +68,23 @@ public class NsdClient {
|
|||||||
@Override
|
@Override
|
||||||
public void onStartDiscoveryFailed(String serviceType, int errorCode) {
|
public void onStartDiscoveryFailed(String serviceType, int errorCode) {
|
||||||
mNsdManager.stopServiceDiscovery(this);
|
mNsdManager.stopServiceDiscovery(this);
|
||||||
Log.e(TAG, "onStartDiscoveryFailed()");
|
Logger.e(TAG, "onStartDiscoveryFailed()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStopDiscoveryFailed(String serviceType, int errorCode) {
|
public void onStopDiscoveryFailed(String serviceType, int errorCode) {
|
||||||
mNsdManager.stopServiceDiscovery(this);
|
mNsdManager.stopServiceDiscovery(this);
|
||||||
Log.e(TAG, "onStopDiscoveryFailed()");
|
Logger.e(TAG, "onStopDiscoveryFailed()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDiscoveryStarted(String serviceType) {
|
public void onDiscoveryStarted(String serviceType) {
|
||||||
Log.e(TAG, "onDiscoveryStarted()");
|
Logger.e(TAG, "onDiscoveryStarted()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDiscoveryStopped(String serviceType) {
|
public void onDiscoveryStopped(String serviceType) {
|
||||||
Log.e(TAG, "onDiscoveryStopped()");
|
Logger.e(TAG, "onDiscoveryStopped()");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,7 +93,7 @@ public class NsdClient {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onServiceFound(NsdServiceInfo serviceInfo) {
|
public void onServiceFound(NsdServiceInfo serviceInfo) {
|
||||||
Log.e(TAG, "onServiceFound()");
|
Logger.e(TAG, "onServiceFound()");
|
||||||
//根据咱服务器的定义名称,指定解析该 NsdServiceInfo
|
//根据咱服务器的定义名称,指定解析该 NsdServiceInfo
|
||||||
if (serviceInfo.getServiceName().equals(mServiceName)) {
|
if (serviceInfo.getServiceName().equals(mServiceName)) {
|
||||||
mNsdManager.resolveService(serviceInfo, getResolveListener());
|
mNsdManager.resolveService(serviceInfo, getResolveListener());
|
||||||
@@ -104,12 +105,12 @@ public class NsdClient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceLost(NsdServiceInfo serviceInfo) {
|
public void onServiceLost(NsdServiceInfo serviceInfo) {
|
||||||
Log.e(TAG, "onServiceLost(): serviceInfo=" + serviceInfo);
|
Logger.e(TAG, "onServiceLost(): serviceInfo=" + serviceInfo);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Handler mHandler = new Handler() {
|
private final Handler mHandler = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
super.handleMessage(msg);
|
super.handleMessage(msg);
|
||||||
@@ -120,7 +121,7 @@ public class NsdClient {
|
|||||||
if (mIServerFound != null) {
|
if (mIServerFound != null) {
|
||||||
mIServerFound.onServerFound(serviceInfo, serviceInfo.getPort());
|
mIServerFound.onServerFound(serviceInfo, serviceInfo.getPort());
|
||||||
}
|
}
|
||||||
Log.e(TAG, " 指定onServiceFound(" + mServiceName + "): Service Info: --> " + serviceInfo);
|
Logger.e(TAG, " 指定onServiceFound(" + mServiceName + "): Service Info: --> " + serviceInfo);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MSG_NULL:
|
case MSG_NULL:
|
||||||
@@ -140,7 +141,7 @@ public class NsdClient {
|
|||||||
return new NsdManager.ResolveListener() {
|
return new NsdManager.ResolveListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
|
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
|
||||||
Log.e(TAG, "onResolveFailed()");
|
Logger.e(TAG, "onResolveFailed()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -149,7 +150,7 @@ public class NsdClient {
|
|||||||
InetAddress host = serviceInfo.getHost();
|
InetAddress host = serviceInfo.getHost();
|
||||||
String serviceName = serviceInfo.getServiceName();
|
String serviceName = serviceInfo.getServiceName();
|
||||||
String hostAddress = serviceInfo.getHost().getHostAddress();
|
String hostAddress = serviceInfo.getHost().getHostAddress();
|
||||||
Log.i(TAG, "onServiceResolved 已解析:" + " host:" + hostAddress + ":" + port + " ----- serviceName: " + serviceName);
|
Logger.i(TAG, "onServiceResolved 已解析:" + " host:" + hostAddress + ":" + port + " ----- serviceName: " + serviceName);
|
||||||
|
|
||||||
mNsdServiceInfoList.add(serviceInfo);
|
mNsdServiceInfoList.add(serviceInfo);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.mogo.telematic.client.handler;
|
package com.mogo.telematic.client.handler;
|
||||||
|
|
||||||
import android.util.Log;
|
import com.elegant.log.simplelog.Logger;
|
||||||
|
|
||||||
import com.mogo.telematic.MogoProtocolMsg;
|
import com.mogo.telematic.MogoProtocolMsg;
|
||||||
import com.mogo.telematic.client.NettyTcpClient;
|
import com.mogo.telematic.client.NettyTcpClient;
|
||||||
import com.mogo.telematic.client.listener.NettyClientListener;
|
import com.mogo.telematic.client.listener.NettyClientListener;
|
||||||
@@ -15,15 +14,15 @@ import io.netty.handler.timeout.IdleStateEvent;
|
|||||||
public class NettyClientHandler extends SimpleChannelInboundHandler<MogoProtocolMsg> {
|
public class NettyClientHandler extends SimpleChannelInboundHandler<MogoProtocolMsg> {
|
||||||
|
|
||||||
private static final String TAG = "NettyClientHandler";
|
private static final String TAG = "NettyClientHandler";
|
||||||
private final boolean isSendheartBeat;
|
private final boolean isSendHeartBeat;
|
||||||
private NettyClientListener listener;
|
private NettyClientListener listener;
|
||||||
private String mSign;
|
private final String mSign;
|
||||||
private Object heartBeatData;
|
private final Object heartBeatData;
|
||||||
|
|
||||||
public NettyClientHandler(NettyClientListener listener, String sign, boolean isSendheartBeat, Object heartBeatData) {
|
public NettyClientHandler(NettyClientListener listener, String sign, boolean isSendHeartBeat, Object heartBeatData) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.mSign = sign;
|
this.mSign = sign;
|
||||||
this.isSendheartBeat = isSendheartBeat;
|
this.isSendHeartBeat = isSendHeartBeat;
|
||||||
this.heartBeatData = heartBeatData;
|
this.heartBeatData = heartBeatData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,17 +50,17 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<MogoProtocol
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendHeartbeat(ChannelHandlerContext ctx) {
|
private void sendHeartbeat(ChannelHandlerContext ctx) {
|
||||||
if (isSendheartBeat) {
|
if (isSendHeartBeat) {
|
||||||
if (heartBeatData == null) {
|
if (heartBeatData == null) {
|
||||||
MogoProtocolMsg heartData = new MogoProtocolMsg(MogoProtocolMsg.NORMAL_DATA, 2, new byte[]{0x00, 0x00});
|
MogoProtocolMsg heartData = new MogoProtocolMsg(MogoProtocolMsg.NORMAL_DATA, 2, new byte[]{0x00, 0x00});
|
||||||
ctx.channel().writeAndFlush(heartData);
|
ctx.channel().writeAndFlush(heartData);
|
||||||
} else if (heartBeatData instanceof MogoProtocolMsg) {
|
} else if (heartBeatData instanceof MogoProtocolMsg) {
|
||||||
ctx.channel().writeAndFlush(heartBeatData);
|
ctx.channel().writeAndFlush(heartBeatData);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "userEventTriggered: heartBeatData type error");
|
Logger.e(TAG, "userEventTriggered: heartBeatData type error");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "不发送心跳");
|
Logger.d(TAG, "不发送心跳");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +71,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<MogoProtocol
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void channelActive(ChannelHandlerContext ctx) {
|
public void channelActive(ChannelHandlerContext ctx) {
|
||||||
Log.e(TAG, "channelActive");
|
Logger.e(TAG, "channelActive");
|
||||||
listener.onClientStatusConnectChanged(ConnectState.STATUS_CONNECT_SUCCESS, mSign);
|
listener.onClientStatusConnectChanged(ConnectState.STATUS_CONNECT_SUCCESS, mSign);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +82,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<MogoProtocol
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void channelInactive(ChannelHandlerContext ctx) {
|
public void channelInactive(ChannelHandlerContext ctx) {
|
||||||
Log.e(TAG, "channelInactive");
|
Logger.e(TAG, "channelInactive");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,7 +93,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<MogoProtocol
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, MogoProtocolMsg msg) throws Exception {
|
protected void channelRead0(ChannelHandlerContext ctx, MogoProtocolMsg msg) throws Exception {
|
||||||
Log.d(TAG, "Client channelRead0:" + msg.toString());
|
Logger.d(TAG, "Client channelRead0:" + msg.toString());
|
||||||
if (msg.getProtocolType() == MogoProtocolMsg.IDENTITY_REGIST) {
|
if (msg.getProtocolType() == MogoProtocolMsg.IDENTITY_REGIST) {
|
||||||
String sn = new String(msg.getBody());
|
String sn = new String(msg.getBody());
|
||||||
NettyTcpClient.sSERVER_SN = sn;
|
NettyTcpClient.sSERVER_SN = sn;
|
||||||
@@ -111,7 +110,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler<MogoProtocol
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||||
Log.e(TAG, "exceptionCaught");
|
Logger.e(TAG, "exceptionCaught");
|
||||||
listener.onClientStatusConnectChanged(ConnectState.STATUS_CONNECT_ERROR, mSign);
|
listener.onClientStatusConnectChanged(ConnectState.STATUS_CONNECT_ERROR, mSign);
|
||||||
cause.printStackTrace();
|
cause.printStackTrace();
|
||||||
ctx.close();
|
ctx.close();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.mogo.telematic.client.handler
|
package com.mogo.telematic.client.handler
|
||||||
|
|
||||||
import android.util.Log
|
import com.elegant.log.simplelog.Logger
|
||||||
import com.mogo.telematic.client.NettyTcpClient
|
import com.mogo.telematic.client.NettyTcpClient
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter
|
import io.netty.channel.ChannelInboundHandlerAdapter
|
||||||
import io.netty.channel.ChannelHandlerContext
|
import io.netty.channel.ChannelHandlerContext
|
||||||
@@ -32,13 +32,13 @@ class ReconnectHandler(private val mNettyClient: NettyTcpClient) : ChannelInboun
|
|||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) {
|
override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) {
|
||||||
Log.e(TAG, "exceptionCaught channelId is:${ctx.channel().id()}, cause message is:${cause.message}")
|
Logger.e(TAG, "exceptionCaught channelId is:${ctx.channel().id()}, cause message is:${cause.message}")
|
||||||
ctx.close()
|
ctx.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
override fun channelInactive(ctx: ChannelHandlerContext) {
|
override fun channelInactive(ctx: ChannelHandlerContext) {
|
||||||
Log.d(TAG, "ReconnectHandler channelInactive ...")
|
Logger.d(TAG, "ReconnectHandler channelInactive ...")
|
||||||
// TODO:(策略暂时耦合在这里,后面使用策略模式)
|
// TODO:(策略暂时耦合在这里,后面使用策略模式)
|
||||||
var allowRetry = false
|
var allowRetry = false
|
||||||
if (retries < maxRetries) {
|
if (retries < maxRetries) {
|
||||||
@@ -54,15 +54,15 @@ class ReconnectHandler(private val mNettyClient: NettyTcpClient) : ChannelInboun
|
|||||||
if (sleepTimeMs > maxSleepMs) {
|
if (sleepTimeMs > maxSleepMs) {
|
||||||
sleepTimeMs = maxSleepMs.toLong()
|
sleepTimeMs = maxSleepMs.toLong()
|
||||||
}
|
}
|
||||||
Log.d(TAG, "${sleepTimeMs}ms后执行重连操作!")
|
Logger.d(TAG, "${sleepTimeMs}ms后执行重连操作!")
|
||||||
scheduledThreadPool.schedule({
|
scheduledThreadPool.schedule({
|
||||||
Log.d(TAG, "Reconnecting server ...")
|
Logger.d(TAG, "Reconnecting server ...")
|
||||||
// 异步重连或单独线程池中同步重连,不要阻塞netty的io线程,同时也不要关闭EventLoopGroup
|
// 异步重连或单独线程池中同步重连,不要阻塞netty的io线程,同时也不要关闭EventLoopGroup
|
||||||
mNettyClient.reconnectServer()
|
mNettyClient.reconnectServer()
|
||||||
}, sleepTimeMs, TimeUnit.MILLISECONDS)
|
}, sleepTimeMs, TimeUnit.MILLISECONDS)
|
||||||
++retries
|
++retries
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Try to reconnect to the server Over Retry count:${retries + 1}")
|
Logger.d(TAG, "Try to reconnect to the server Over Retry count:${retries + 1}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,8 @@ package com.mogo.telematic.server;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.nsd.NsdManager;
|
import android.net.nsd.NsdManager;
|
||||||
import android.net.nsd.NsdServiceInfo;
|
import android.net.nsd.NsdServiceInfo;
|
||||||
import android.util.Log;
|
|
||||||
|
import com.elegant.log.simplelog.Logger;
|
||||||
|
|
||||||
public class NSDServer {
|
public class NSDServer {
|
||||||
public static final String TAG = "NSDServer";
|
public static final String TAG = "NSDServer";
|
||||||
@@ -25,7 +26,7 @@ public class NSDServer {
|
|||||||
mRegistrationListener = new NsdManager.RegistrationListener() {
|
mRegistrationListener = new NsdManager.RegistrationListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onRegistrationFailed(NsdServiceInfo serviceInfo, int errorCode) {
|
public void onRegistrationFailed(NsdServiceInfo serviceInfo, int errorCode) {
|
||||||
Log.e(TAG, "NsdServiceInfo onRegistrationFailed");
|
Logger.e(TAG, "NsdServiceInfo onRegistrationFailed");
|
||||||
if (registerState != null) {
|
if (registerState != null) {
|
||||||
registerState.onRegistrationFailed(serviceInfo, errorCode);
|
registerState.onRegistrationFailed(serviceInfo, errorCode);
|
||||||
}
|
}
|
||||||
@@ -33,7 +34,7 @@ public class NSDServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnregistrationFailed(NsdServiceInfo serviceInfo, int errorCode) {
|
public void onUnregistrationFailed(NsdServiceInfo serviceInfo, int errorCode) {
|
||||||
Log.i(TAG, "onUnregistrationFailed serviceInfo: " + serviceInfo + " ,errorCode:" + errorCode);
|
Logger.i(TAG, "onUnregistrationFailed serviceInfo: " + serviceInfo + " ,errorCode:" + errorCode);
|
||||||
if (registerState != null) {
|
if (registerState != null) {
|
||||||
registerState.onUnRegistrationFailed(serviceInfo, errorCode);
|
registerState.onUnRegistrationFailed(serviceInfo, errorCode);
|
||||||
}
|
}
|
||||||
@@ -42,8 +43,8 @@ public class NSDServer {
|
|||||||
@Override
|
@Override
|
||||||
public void onServiceRegistered(NsdServiceInfo serviceInfo) {
|
public void onServiceRegistered(NsdServiceInfo serviceInfo) {
|
||||||
mServerName = serviceInfo.getServiceName();
|
mServerName = serviceInfo.getServiceName();
|
||||||
Log.i(TAG, "onServiceRegistered: " + serviceInfo.toString());
|
Logger.i(TAG, "onServiceRegistered: " + serviceInfo.toString());
|
||||||
Log.i(TAG, "mServerName onServiceRegistered: " + mServerName);
|
Logger.i(TAG, "mServerName onServiceRegistered: " + mServerName);
|
||||||
if (registerState != null) {
|
if (registerState != null) {
|
||||||
registerState.onServiceRegistered(serviceInfo);
|
registerState.onServiceRegistered(serviceInfo);
|
||||||
}
|
}
|
||||||
@@ -51,7 +52,7 @@ public class NSDServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceUnregistered(NsdServiceInfo serviceInfo) {
|
public void onServiceUnregistered(NsdServiceInfo serviceInfo) {
|
||||||
Log.i(TAG, "onServiceUnregistered serviceInfo: " + serviceInfo);
|
Logger.i(TAG, "onServiceUnregistered serviceInfo: " + serviceInfo);
|
||||||
if (registerState != null) {
|
if (registerState != null) {
|
||||||
registerState.onServiceUnregistered(serviceInfo);
|
registerState.onServiceUnregistered(serviceInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ package com.mogo.telematic.server.netty;
|
|||||||
import static com.mogo.telematic.MogoProtocolMsg.IDENTITY_REGIST;
|
import static com.mogo.telematic.MogoProtocolMsg.IDENTITY_REGIST;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import com.elegant.log.simplelog.Logger;
|
||||||
|
|
||||||
import com.mogo.telematic.MogoProtocolMsg;
|
import com.mogo.telematic.MogoProtocolMsg;
|
||||||
|
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
@@ -32,8 +31,8 @@ public class MogoProtocolServerHandler extends SimpleChannelInboundHandler<MogoP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, MogoProtocolMsg msg) throws Exception {
|
protected void channelRead0(ChannelHandlerContext ctx, MogoProtocolMsg msg) throws Exception {
|
||||||
Log.d(TAG, "server$channelRead0():" + msg.toString());
|
Logger.d(TAG, "server$channelRead0():" + msg.toString());
|
||||||
if (msg.getProtocolType() == IDENTITY_REGIST) {
|
if (msg.getProtocolType() == MogoProtocolMsg.IDENTITY_REGIST) {
|
||||||
String sn = new String(msg.getBody());
|
String sn = new String(msg.getBody());
|
||||||
NettyTcpServer.getInstance().putChannelSN(ctx.channel().id(), sn);
|
NettyTcpServer.getInstance().putChannelSN(ctx.channel().id(), sn);
|
||||||
} else {
|
} else {
|
||||||
@@ -51,7 +50,7 @@ public class MogoProtocolServerHandler extends SimpleChannelInboundHandler<MogoP
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||||
Log.e(TAG, "channelActive");
|
Logger.e(TAG, "channelActive");
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
mListener.onChannelConnect(ctx.channel());
|
mListener.onChannelConnect(ctx.channel());
|
||||||
}
|
}
|
||||||
@@ -72,7 +71,7 @@ public class MogoProtocolServerHandler extends SimpleChannelInboundHandler<MogoP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||||
Log.e(TAG, "channelInactive");
|
Logger.e(TAG, "channelInactive");
|
||||||
// NettyTcpServer.getInstance().setConnectStatus(false);
|
// NettyTcpServer.getInstance().setConnectStatus(false);
|
||||||
NettyTcpServer.getInstance().removeChannelSN(ctx.channel().id());
|
NettyTcpServer.getInstance().removeChannelSN(ctx.channel().id());
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import static com.mogo.telematic.MogoLengthFrameDecoder.LENGTH_FIELD_OFFSET;
|
|||||||
import static com.mogo.telematic.MogoLengthFrameDecoder.LENGTH_FIELD_SIZE;
|
import static com.mogo.telematic.MogoLengthFrameDecoder.LENGTH_FIELD_SIZE;
|
||||||
import static com.mogo.telematic.MogoLengthFrameDecoder.MAX_FRAME_LENGTH;
|
import static com.mogo.telematic.MogoLengthFrameDecoder.MAX_FRAME_LENGTH;
|
||||||
|
|
||||||
import android.util.Log;
|
import com.elegant.log.simplelog.Logger;
|
||||||
|
|
||||||
import com.mogo.telematic.MogoLengthFrameDecoder;
|
import com.mogo.telematic.MogoLengthFrameDecoder;
|
||||||
import com.mogo.telematic.MogoMessageEncoder;
|
import com.mogo.telematic.MogoMessageEncoder;
|
||||||
import com.mogo.telematic.MogoProtocolMsg;
|
import com.mogo.telematic.MogoProtocolMsg;
|
||||||
@@ -104,7 +103,7 @@ public class NettyTcpServer {
|
|||||||
|
|
||||||
// Bind and start to accept incoming connections.
|
// Bind and start to accept incoming connections.
|
||||||
ChannelFuture f = b.bind().sync();
|
ChannelFuture f = b.bind().sync();
|
||||||
Log.e(TAG, NettyTcpServer.class.getName() + " started and listen on " + f.channel().localAddress());
|
Logger.e(TAG, NettyTcpServer.class.getName() + " started and listen on " + f.channel().localAddress());
|
||||||
isServerStart = true;
|
isServerStart = true;
|
||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
mListener.onStartServer();
|
mListener.onStartServer();
|
||||||
@@ -114,7 +113,7 @@ public class NettyTcpServer {
|
|||||||
// shut down your server.
|
// shut down your server.
|
||||||
f.channel().closeFuture().sync();
|
f.channel().closeFuture().sync();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, e.getLocalizedMessage());
|
Logger.e(TAG, e.getLocalizedMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
isServerStart = false;
|
isServerStart = false;
|
||||||
@@ -163,11 +162,11 @@ public class NettyTcpServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChannelFutureListener mProxyListener = channelFuture -> {
|
private final ChannelFutureListener mProxyListener = channelFuture -> {
|
||||||
if (channelFuture.isSuccess()) {
|
if (channelFuture.isSuccess()) {
|
||||||
Log.d(TAG, "SendMsgToAllClients result was successful");
|
Logger.d(TAG, "SendMsgToAllClients result was successful");
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "SendMsgToAllClients result was unsuccessful");
|
Logger.d(TAG, "SendMsgToAllClients result was unsuccessful");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.mogo.cloud.tanlu.api;
|
package com.mogo.cloud.tanlu.api;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.elegant.network.utils.GsonUtil;
|
import com.elegant.network.utils.GsonUtil;
|
||||||
import com.mogo.cloud.network.BaseData;
|
import com.mogo.cloud.network.BaseData;
|
||||||
@@ -10,7 +9,6 @@ import com.mogo.cloud.network.RetrofitFactory;
|
|||||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||||
import com.mogo.cloud.tanlu.bean.RoadInfoRequest;
|
import com.mogo.cloud.tanlu.bean.RoadInfoRequest;
|
||||||
import com.mogo.cloud.tanlu.bean.RoadInfos;
|
import com.mogo.cloud.tanlu.bean.RoadInfos;
|
||||||
import com.mogo.cloud.tanlu.constant.HttpConstant;
|
|
||||||
import com.mogo.cloud.tanlu.net.TanluApiService;
|
import com.mogo.cloud.tanlu.net.TanluApiService;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -88,9 +86,7 @@ public class MogoRoadSearchManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
|
||||||
Log.d(HttpConstant.TAG, "queryRoadInfos onComplete ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.mogo.cloud.tanlu.core;
|
package com.mogo.cloud.tanlu.core;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.mogo.cloud.network.BaseData;
|
import com.mogo.cloud.network.BaseData;
|
||||||
|
|||||||
Reference in New Issue
Block a user