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

internal class V2XMessageListener_402000(val cbs: Iterable<IV2XCallback>?): IMogoCloudSocketOnMessageListener<V2XOptimalRoute> {

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

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