[6.4.0]
[局域网内网络通讯]
This commit is contained in:
@@ -7,15 +7,10 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.och.biz.login.bean.DriverStatusQueryRespBean
|
||||
import com.mogo.och.common.module.biz.lansocket.LoginLanSocket
|
||||
import com.mogo.och.common.module.biz.login.LoginStatusManager
|
||||
import com.mogo.och.common.module.manager.socket.lan.LanSocketManager
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.AppConnectMsg
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.BusCacheKey
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.ChangeBusinessType
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.LoginCacheStatus
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.common.module.utils.ProjectUtils
|
||||
import com.mogo.och.data.manager.cache.CacheDataManager
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
|
||||
@@ -8,9 +8,12 @@ import com.mogo.och.common.module.biz.login.LoginStatusEnum
|
||||
import com.mogo.och.common.module.biz.login.LoginStatusManager
|
||||
import com.mogo.och.common.module.manager.loop.BizLoopManager
|
||||
import com.mogo.och.common.module.manager.loop.LoopInfo
|
||||
import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener
|
||||
import com.mogo.och.common.module.manager.socket.lan.LanSocketManager
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.BaseDPMsg
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.BusinessType
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.ChangeBusinessType
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.EnvCheck
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.EnvType
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.ProjectType
|
||||
@@ -18,35 +21,59 @@ import com.mogo.och.common.module.manager.socket.lan.bean.VehicleType
|
||||
import com.mogo.och.common.module.utils.Project
|
||||
import com.mogo.och.common.module.utils.ProjectUtils
|
||||
|
||||
object LoginLanSocket : ILoginCallback {
|
||||
object LoginLanDriverSocket : ILoginCallback {
|
||||
private const val TAG = "LoginLanSocket"
|
||||
|
||||
var vehicleType:VehicleType?=null
|
||||
var businessType:BusinessType?=null
|
||||
var projectType:ProjectType?=null
|
||||
var envType:EnvType?=null
|
||||
var vehicleType: VehicleType? = null
|
||||
var businessType: BusinessType? = null
|
||||
var projectType: ProjectType? = null
|
||||
var envType: EnvType? = null
|
||||
|
||||
fun load(){
|
||||
// 客户端注册
|
||||
private val registerListener = object : ILanMessageListener<BaseDPMsg> {
|
||||
override fun target(): Class<BaseDPMsg> {
|
||||
return BaseDPMsg::class.java
|
||||
}
|
||||
|
||||
override fun onMsgReceived(obj: Array<in BaseDPMsg>) {
|
||||
println("-------${obj}")
|
||||
getEnvCheck()
|
||||
val msg =
|
||||
ChangeBusinessType(vehicleType!!, businessType!!, projectType!!, envType!!)
|
||||
LanSocketManager.sendMsgToClient(msg)
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
fun load() {
|
||||
LanSocketManager.load()
|
||||
}
|
||||
|
||||
init {
|
||||
LoginStatusManager.addListener(TAG, this)
|
||||
LanSocketManager.registerSocketMessageListener(
|
||||
DPMsgType.TYPE_CLIENT_REGISTER.type,
|
||||
TAG,
|
||||
registerListener
|
||||
)
|
||||
}
|
||||
|
||||
// 司机端发送业务模式更改和环境校验
|
||||
override fun onStatusChange(currentStatus: LoginStatusEnum?) {
|
||||
super.onStatusChange(currentStatus)
|
||||
when (currentStatus) {
|
||||
LoginStatusEnum.None -> {}
|
||||
LoginStatusEnum.Login -> {
|
||||
getEnvCheck()
|
||||
val msg = ChangeBusinessType(vehicleType!!, businessType!!, projectType!!, envType!!)
|
||||
val msg =
|
||||
ChangeBusinessType(vehicleType!!, businessType!!, projectType!!, envType!!)
|
||||
LanSocketManager.sendMsgToClient(msg)
|
||||
BizLoopManager.setLoopFunction(TAG, LoopInfo(60*5, ::loopCheck))
|
||||
BizLoopManager.setLoopFunction(TAG, LoopInfo(60 * 5, ::loopCheck))
|
||||
}
|
||||
LoginStatusEnum.Logout -> {
|
||||
|
||||
else -> {
|
||||
BizLoopManager.removeLoopFunction(TAG)
|
||||
val msg = ChangeBusinessType(vehicleType!!, BusinessType.none, projectType!!, envType!!)
|
||||
val msg =
|
||||
ChangeBusinessType(vehicleType!!, BusinessType.none, projectType!!, envType!!)
|
||||
LanSocketManager.sendMsgToClient(msg)
|
||||
}
|
||||
}
|
||||
@@ -58,7 +85,7 @@ object LoginLanSocket : ILoginCallback {
|
||||
LanSocketManager.sendMsgToClient(msg)
|
||||
}
|
||||
|
||||
private fun getEnvCheck(){
|
||||
private fun getEnvCheck() {
|
||||
vehicleType =
|
||||
if (AppIdentityModeUtils.isT1T2(FunctionBuildConfig.appIdentityMode)) {
|
||||
VehicleType.T1T2
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.mogo.och.common.module.biz.lansocket
|
||||
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener
|
||||
import com.mogo.och.common.module.manager.socket.lan.LanSocketManager
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.BaseDPMsg
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.ChangeBusinessType
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType
|
||||
import com.mogo.och.common.module.manager.socket.lan.bean.EnvCheck
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
object LoginLanPassengerSocket : IReceivedMsgListener {
|
||||
private const val TAG = "LoginLanSocket"
|
||||
|
||||
private var driverSn: String by Delegates.observable("") { _, oldV, newV ->
|
||||
if (oldV != newV) {
|
||||
// 司机屏发生变化
|
||||
val msg = BaseDPMsg(type = DPMsgType.TYPE_CLIENT_REGISTER.type)
|
||||
LanSocketManager.sendMsgToServer(msg)
|
||||
}
|
||||
}
|
||||
|
||||
// 环境监测
|
||||
private val checkListener = object : ILanMessageListener<EnvCheck> {
|
||||
override fun target(): Class<EnvCheck> {
|
||||
return EnvCheck::class.java
|
||||
}
|
||||
|
||||
override fun onMsgReceived(obj: Array<in EnvCheck>) {
|
||||
println("EnvCheck-------${obj}")
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// 环境监测+业务展示和跳转
|
||||
private val changeBusinessType = object : ILanMessageListener<ChangeBusinessType> {
|
||||
override fun target(): Class<ChangeBusinessType> {
|
||||
return ChangeBusinessType::class.java
|
||||
}
|
||||
|
||||
override fun onMsgReceived(obj: Array<in ChangeBusinessType>) {
|
||||
println("ChangeBusinessType -------${obj}")
|
||||
if (obj.isNotEmpty()) {
|
||||
var first = obj.first() as ChangeBusinessType
|
||||
println("ChangeBusinessType -------${first}")
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
fun load() {
|
||||
LanSocketManager.load()
|
||||
}
|
||||
|
||||
init {
|
||||
//监听司机端消息
|
||||
CallerTelematicListenerManager.addListener(TAG, this)
|
||||
// 乘客屏
|
||||
LanSocketManager.registerSocketMessageListener(
|
||||
DPMsgType.TYPE_ENV_CHECK.type,
|
||||
TAG,
|
||||
checkListener
|
||||
)
|
||||
LanSocketManager.registerSocketMessageListener(
|
||||
DPMsgType.TYPE_CHANGE_BUSINESS_TYPE.type,
|
||||
TAG,
|
||||
changeBusinessType
|
||||
)
|
||||
}
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
|
||||
}
|
||||
|
||||
override fun onReceivedServerSn(sn: String?) {
|
||||
Logger.d(TAG, "司机屏sn:$sn")
|
||||
driverSn = sn ?: ""
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -13,6 +13,6 @@ interface ILanMessageListener<T:BaseDPMsg> {
|
||||
|
||||
fun target(): Class<T>
|
||||
|
||||
fun <T> onMsgReceived(obj: T)
|
||||
fun onMsgReceived(obj: Array<in T>)
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ object LanSocketManager : IReceivedMsgListener {
|
||||
CallerTelematicListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
fun load(){
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun sendMsgToClient(msg: BaseDPMsg?) {
|
||||
val message = GsonUtils.toJson(msg)
|
||||
@@ -52,7 +56,8 @@ object LanSocketManager : IReceivedMsgListener {
|
||||
String(byteArray), target
|
||||
)
|
||||
}
|
||||
listeners.value.onMsgReceived(fromJson)
|
||||
|
||||
listeners.value.onMsgReceived(arrayOf(fromJson))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
|
||||
open class BaseDPMsg(
|
||||
open var type: Int,
|
||||
open var type: Int = DPMsgType.TYPE_CLIENT_REGISTER.type,
|
||||
open var msgVersion: Int = 1,
|
||||
open var targetScreenTypes: MutableList<ScreenType> =
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
|
||||
@@ -18,34 +18,6 @@ enum class DPMsgType(val type: Int) {
|
||||
TYPE_WRITEOFF_INFO(8), //核销信息
|
||||
TYPE_WRITEOFF_DEVICES_INFO(9), //核销设备信息
|
||||
TYPE_CHANGE_BUSINESS_TYPE(10), //业务模式切换
|
||||
TYPE_ENV_CHECK(11); //环境核验
|
||||
|
||||
companion object {
|
||||
fun getValue(type: Int, byteArray: ByteArray):BaseDPMsg? {
|
||||
when (type) {
|
||||
TYPE_COMMON.type -> {
|
||||
return GsonUtils.fromJson(
|
||||
String(byteArray), AppConnectMsg::class.java
|
||||
) as AppConnectMsg
|
||||
}
|
||||
TYPE_CHANGE_DEST.type -> {
|
||||
return GsonUtils.fromJson(
|
||||
String(byteArray), ChangeDestMsg::class.java
|
||||
) as ChangeDestMsg
|
||||
}
|
||||
TYPE_OPEN_CLOSE_DOOR.type -> {}
|
||||
TYPE_ORDER_CLOSED.type -> {}
|
||||
TYPE_TASK_DETAILS.type -> {}
|
||||
TYPE_LOGIN_STATUS.type -> {}
|
||||
TYPE_ARRIVEDEST_STATUS.type -> {}
|
||||
TYPE_ORDER_CLOSED_BY_M1_STATUS.type -> {}
|
||||
TYPE_WRITEOFF_INFO.type -> {}
|
||||
TYPE_WRITEOFF_DEVICES_INFO.type -> {}
|
||||
TYPE_CHANGE_BUSINESS_TYPE.type -> {}
|
||||
TYPE_ENV_CHECK.type -> {}
|
||||
else -> {}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
TYPE_ENV_CHECK(11), //环境核验
|
||||
TYPE_CLIENT_REGISTER(12); //客户端注册 服务端需要
|
||||
}
|
||||
@@ -17,7 +17,8 @@ import com.mogo.eagle.core.function.hmi.ui.setting.ToggleDebugView
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.StatusBarView
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.och.common.module.biz.lansocket.LoginLanSocket
|
||||
import com.mogo.och.common.module.biz.lansocket.LoginLanDriverSocket
|
||||
import com.mogo.och.common.module.biz.lansocket.LoginLanPassengerSocket
|
||||
import com.mogo.och.common.module.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.biz.login.BusinessEnum
|
||||
import com.mogo.och.common.module.biz.login.ILoginCallback
|
||||
@@ -40,9 +41,12 @@ abstract class FacadeProvider : IMoGoFunctionProvider, ILoginCallback {
|
||||
override fun init(context: Context) {
|
||||
d(TAG, "FacadeProvider:init")
|
||||
LoginStatusManager.addListener(TAG, this)
|
||||
LoginLanSocket.load()
|
||||
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){
|
||||
LoginStatusManager.queryLoginStatusByNet()
|
||||
LoginLanDriverSocket.load()
|
||||
}else{
|
||||
LoginLanPassengerSocket.load()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user