有没有可能因我消息是自定义的?也不能说是自定义吧,im的消息发送时,我通过给TextMessageContent的 content 设置个json字符的,方法发送的,收到在解析的这个json,但是音频通过直接调用的startCall函数,没设置啥呢 下面时我调用startcall的代码
override fun call(targetId: String, callType: CallType, token: String, channelName: String) :Boolean{
//真正的音频入口
userCoroutineScope.launch(Dispatchers.Main){
val isAudioOnly = callType==CallType.VOICE
val conversation = Conversation(Conversation.ConversationType.Single, targetId)
val session = AVEngineKit.Instance().startCall(conversation, listOf(targetId), isAudioOnly, null)
Timber.i("${TAG} call: $session")
}
return true
}
下面是我发送IM消息的代码
override suspend fun sendCustomMessage(
msg: String,
receiverId: String,
isGroup: Boolean
): Boolean {
Timber.i("发送消息: msg = ${msg} receiverId = ${receiverId} isGroup = ${isGroup}")
val conversation = Conversation()
var targetId: String
if (isGroup) {
targetId = imConvertor.groupWildfireImId(receiverId)
conversation.type = Conversation.ConversationType.Group
} else {
targetId = imConvertor.individualImId(receiverId)
conversation.type = Conversation.ConversationType.Single
}
Timber.i("野火 targetId = $targetId")
conversation.target = targetId
val message = Message().also {
//先用TextMessageContent 试试,不行再去自定义消息内容
it.content = TextMessageContent(msg)
it.conversation = conversation
if (conversation.type ==Conversation.ConversationType.Single){
it.toUsers = arrayOf(targetId)
}
}
return suspendCancellableCoroutine {
ChatManager.Instance().sendMessage(message, object :
SendMessageCallback {
override fun onSuccess(messageUid: Long, timestamp: Long) {
Timber.i("发送消息成功 uid = ${messageUid}")
it.resume(true)
}
override fun onFail(errorCode: Int) {
Timber.e("发送消息失败 code =${errorCode}")
it.resume(false)
}
override fun onPrepare(messageId: Long, savedTime: Long) {
Timber.e("发送消息onPrepare")
}
})
}
}