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