package com.yidian.common.chameleon

import com.yidian.chameleon.js.BridgeService
import com.yidian.chameleon.js.BridgeService.IAppDispatcher
import io.reactivex.Observable
import org.json.JSONObject

class ChameleonServiceRouter: IAppDispatcher {

    override fun connectEventReceiver(eventReceiver: IAppDispatcher.IServiceEventReceiver?): String {
        return ""
    }

    override fun dispatchCall(
        module: String?,
        action: String?,
        params: JSONObject?,
        options: JSONObject?
    ): Observable<BridgeService.JsResult> {
        ChameleonServiceManager.dispatchEvent(ChameleonEvent(module,action,params,options))
        val jsResult = BridgeService.JsResult(params)
        return Observable.just(jsResult)
    }


    override fun disconnectEventReceiver(evToken: String?) {}
}