package com.mogo.v2x.socket

import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener
import com.mogo.v2x.V2XManager
import com.mogo.v2x.callback.IV2XCallback
import com.mogo.v2x.data.V2XAdvanceWarning
import com.mogo.v2x.event.V2XEvent
import com.mogo.v2x.event.V2XEvent.RoadAI
import com.mogo.v2x.logger.Logger
import roadwork.Road.RW_PB

internal class V2XMessageListener_503000(val cbs: Iterable<IV2XCallback>?): IMogoCloudSocketOnMessageListener<RW_PB> {

    override fun target(msgType: Int): Class<RW_PB> = RW_PB::class.java

    override fun onMsgReceived(msgType: Int, data: RW_PB?) {
        if (msgType != 503000) {
            return
        }
        if (data == null) {
            Logger.i(V2XManager.TAG, "V2XMessageListener_503000：message is null!")
            return
        }
        Logger.i(V2XManager.TAG, "V2XMessageListener_503000:$data")
        cbs?.forEach {
            it.onAck(RoadAI(data = data))
        }
    }
}