insertOutgoingMessage static method

Future<void> insertOutgoingMessage(
  1. int conversationType,
  2. String targetId,
  3. int sendStatus,
  4. MessageContent content,
  5. int sendTime,
  6. dynamic finished(
    1. Message? msg,
    2. int? code
    )?,
)

插入一条发出的消息

conversationType 会话类型,参见枚举 RCConversationType

targetId 会话 id

sendStatus 发送状态,参见枚举 RCSentStatus

content 消息内容,参见 MessageContent

sendTime 发送时间

finished 回调结果,会告知具体的消息和对应的错误码

Implementation

static Future<void> insertOutgoingMessage(int conversationType, String targetId, int sendStatus, MessageContent content, int sendTime, Function(Message? msg, int? code)? finished) async {
  String? jsonStr = content.encode();
  String? objName = content.getObjectName();
  Map map = {"conversationType": conversationType, "targetId": targetId, "sendStatus": sendStatus, "objectName": objName, "content": jsonStr, "sendTime": sendTime};
  Map msgMap = await _channel.invokeMethod(RCMethodKey.InsertOutgoingMessage, map);
  String? msgString = msgMap["message"];
  int? code = msgMap["code"];
  if (msgString == null) {
    if (finished != null) {
      finished(null, code);
    }
    return;
  }
  Message? message = MessageFactory.instance!.string2Message(msgString);
  if (finished != null) {
    finished(message, code);
  }
}