[Feat]支持跨模块调用司乘屏通信的能力
This commit is contained in:
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.function.api.telematic.IMogoTelematicProvider
|
||||
import com.mogo.telematic.MogoProtocolMsg
|
||||
import com.mogo.telematic.NSDNettyManager
|
||||
|
||||
@Route(path = MogoServicePaths.PATH_TELEMATIC_PROVIDER)
|
||||
@@ -26,4 +27,16 @@ class MoGoTelematicProvider: IMogoTelematicProvider {
|
||||
override fun getServerToken(): String {
|
||||
return NSDNettyManager.getInstance().serverSn
|
||||
}
|
||||
|
||||
override fun sendMsgToAllClients(type: Int, byteArray: ByteArray) {
|
||||
NSDNettyManager.getInstance().sendMsgToAllClients(
|
||||
MogoProtocolMsg(type, byteArray.size, byteArray)
|
||||
)
|
||||
}
|
||||
|
||||
override fun sendMsgToServer(type: Int, byteArray: ByteArray) {
|
||||
NSDNettyManager.getInstance().sendMogoProtocolMsgToServer(
|
||||
MogoProtocolMsg(type, byteArray.size, byteArray),
|
||||
null)
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,12 @@ import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS
|
||||
import com.mogo.eagle.core.data.telematic.TelematicConstant
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setDemoMode
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setIgnoreConditionDraw
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
@@ -122,6 +124,9 @@ class TeleMsgHandler : IMsgHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
TelematicConstant.BUSINESS_STRING -> {
|
||||
CallerTelematicListenerManager.invokeReceivedMsg(TelematicConstant.BUSINESS_STRING, it.body)
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
@@ -166,6 +171,9 @@ class TeleMsgHandler : IMsgHandler {
|
||||
invokeNettyConnResult("司机屏SN未获取到,不发送给乘客屏")
|
||||
}
|
||||
}
|
||||
TelematicConstant.BUSINESS_STRING -> {
|
||||
CallerTelematicListenerManager.invokeReceivedMsg(TelematicConstant.BUSINESS_STRING, it.body)
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.mogo.eagle.core.data.telematic
|
||||
|
||||
class TelematicConstant {
|
||||
companion object {
|
||||
const val BUSINESS_STRING = 100
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,8 @@ interface IMogoTelematicProvider: IProvider {
|
||||
fun getServerIp(): String
|
||||
|
||||
fun getServerToken(): String
|
||||
|
||||
fun sendMsgToAllClients(type: Int, byteArray: ByteArray)
|
||||
|
||||
fun sendMsgToServer(type: Int, byteArray: ByteArray)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.mogo.eagle.core.function.api.telematic
|
||||
|
||||
interface IReceivedMsgListener {
|
||||
fun onReceivedMsg(type: Int, byteArray: ByteArray)
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.eagle.core.function.call.telematic
|
||||
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
|
||||
object CallerTelematicListenerManager: CallerBase<IReceivedMsgListener>() {
|
||||
|
||||
fun invokeReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onReceivedMsg(type, byteArray)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,20 @@ object CallerTelematicManager {
|
||||
fun getServerToken(): String {
|
||||
return providerApi?.getServerToken() ?: ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送数据给所有客户端
|
||||
* type:保存在TelematicConstant中
|
||||
*/
|
||||
fun sendMsgToAllClients(type: Int, byteArray: ByteArray) {
|
||||
providerApi?.sendMsgToAllClients(type, byteArray)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送数据给服务端
|
||||
* type:保存在TelematicConstant中
|
||||
*/
|
||||
fun sendMsgToServer(type: Int, byteArray: ByteArray) {
|
||||
providerApi?.sendMsgToServer(type, byteArray)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user