loadMessage method
- String messageId
~english Gets the message with a specific message ID.
If the message is already loaded into the memory cache, the message will be directly returned; otherwise, the message will be loaded from the local database and loaded in the memory.
Param messageId
The message ID.
Return The message instance.
Throws A description of the exception. See ChatError. ~end
~chinese 获取指定 ID 的消息。
优先从内存中加载,如果内存中没有则从数据库中加载,并将其插入到内存中。
Param messageId
消息 ID。
Return 消息实例。
Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 ChatError。 ~end
Implementation
Future<ChatMessage?> loadMessage(String messageId) async {
Map req = this._toJson();
req['msg_id'] = messageId;
Map result = await _emConversationChannel.invokeMethod(
ChatMethodKeys.loadMsgWithId, req);
try {
ChatError.hasErrorFromResult(result);
if (result[ChatMethodKeys.loadMsgWithId] != null) {
return ChatMessage.fromJson(result[ChatMethodKeys.loadMsgWithId]);
} else {
return null;
}
} on ChatError catch (e) {
throw e;
}
}