创建消息
接口
kotlin
suspend fun createTextMessage(text: String): BimTextMessage
suspend fun createTextMessage(text: String, atAll: Boolean, atList: List<BimContact>): BimTextMessage
suspend fun createImageMessage(imagePath: String): BimImageMessage
suspend fun createFileMessage(filePath: String, fileName: String): BimFileMessage
suspend fun createVoiceMessage(filePath: String, duration: Long): BimVoiceMessage
suspend fun createVideoMessage(videoPath: String, duration: Long, snapshotPath: String): BimVideoMessage
suspend fun createFaceMessage(name: String?, themeName: String, stickerName: String, width: Long, height: Long, isGif: Boolean): BimFaceMessage
suspend fun createLocationMessage(longitude: Double, latitude: Double, address: String?, name: String?): BimLocationMessage
suspend fun createCustomMessage(content: ByteArray): BimCustomMessage
suspend fun createCustomMessage(content: ByteArray, desc: String?): BimCustomMessage
suspend fun createMultipartMessage(messages: List<BimMessage>, title: String, abstractList: List<String>): BimMultipartMessage1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
代码示例
kotlin
val chat = BimImManager.getInstance().chatService
val text = chat.createTextMessage("hello")
val at = chat.createTextMessage("@all hello", true, emptyList())
val image = chat.createImageMessage("/tmp/demo.jpg")
val location = chat.createLocationMessage(113.2644, 23.1291, address = null, name = null)
println("text=${text.id}, at=${at.id}, image=${image.id}, location=${location.id}")1
2
3
4
5
6
7
2
3
4
5
6
7
图片、视频、文件和语音消息由 SDK 负责媒体准备和发送;BimFaceMessage 的资源由宿主根据 themeName、stickerName 解析。位置消息只有经纬度必填,address 和 name 可为空。
