2024-11-17 20:07:42 +08:00
|
|
|
package com.aiosman.ravenow.utils
|
2024-09-27 21:29:30 +08:00
|
|
|
|
|
|
|
|
import com.tencent.imsdk.v2.V2TIMManager
|
|
|
|
|
import com.tencent.imsdk.v2.V2TIMValueCallback
|
|
|
|
|
import kotlin.coroutines.suspendCoroutine
|
|
|
|
|
|
|
|
|
|
object TrtcHelper {
|
|
|
|
|
suspend fun loadUnreadCount(): Long {
|
|
|
|
|
return suspendCoroutine { continuation ->
|
|
|
|
|
V2TIMManager.getConversationManager()
|
|
|
|
|
.getTotalUnreadMessageCount(object : V2TIMValueCallback<Long> {
|
|
|
|
|
override fun onSuccess(t: Long?) {
|
|
|
|
|
continuation.resumeWith(Result.success(t ?: 0))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onError(code: Int, desc: String?) {
|
|
|
|
|
continuation.resumeWith(Result.failure(Exception("Error $code: $desc")))
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|