[Chat]车聊聊架构升级
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.mogo.eagle.core.function.call.chat
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.function.api.chat.IMoGoChatProvider
|
||||
import com.mogo.eagle.core.function.api.chat.biz.ChatConsts
|
||||
import com.mogo.eagle.core.function.api.chat.biz.ChatParams
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.kotlin.lifeCycleScope
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
|
||||
object CallerChatManager: CallerBase() {
|
||||
|
||||
private val provider by lazy {
|
||||
getApiInstance(IMoGoChatProvider::class.java, ChatConsts.CHAT_PROVIDER_PATH)?.chat()
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
fun call(ctx: Context , sn: String) {
|
||||
val facade = provider ?: return
|
||||
facade
|
||||
.call(ChatParams(sn))
|
||||
.onEach {
|
||||
Log.e(ChatConsts.TAG, "call state: $it")
|
||||
}
|
||||
.launchIn(ctx.lifeCycleScope)
|
||||
}
|
||||
|
||||
fun chat() = provider
|
||||
}
|
||||
Reference in New Issue
Block a user