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.event.V2XEvent
import com.mogo.v2x.data.V2XWarningTarget
import com.mogo.v2x.logger.Logger

internal class V2XMessageListener_401018(val cbs: Iterable<IV2XCallback>?): IMogoCloudSocketOnMessageListener<V2XWarningTarget> {

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

    override fun onMsgReceived(msgType: Int, data: V2XWarningTarget?) {
        if (msgType != 401018) {
            return
        }
        if (data == null) {
            Logger.i(V2XManager.TAG, "V2XMessageListener_401018：message is null!")
            return
        }
        Logger.i(V2XManager.TAG, "V2XMessageListener_401018:$data")
        cbs?.forEach {
            it.onAck(V2XEvent.Warning(data = data))
        }
    }
}