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.logger.Logger

internal class V2XMessageListener_404000(val cbs: Iterable<IV2XCallback>?): IMogoCloudSocketOnMessageListener<V2XAdvanceWarning> {

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

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