forwardMessageByStep static method

Future<void> forwardMessageByStep(
  1. int conversationType,
  2. String targetId,
  3. Message message, {
  4. dynamic finished(
    1. int messageId,
    2. int status,
    3. int code
    )?,
})

Implementation

static Future<void> forwardMessageByStep(int conversationType, String targetId, Message message, {Function(int messageId, int status, int code)? finished}) async {
  Map msgMap = MessageFactory.instance!.message2Map(message);
  // 此处获取当前时间戳传给原生方法,并且当做 sendMessageCallbacks 的 key 记录 finished
  DateTime time = DateTime.now();
  int timestamp = time.millisecondsSinceEpoch;

  Map map = {"message": msgMap, "conversationType": conversationType, "targetId": targetId, "timestamp": timestamp};

  if (finished != null) {
    sendMessageCallbacks[timestamp] = finished;
  }
  await _channel.invokeMethod(RCMethodKey.ForwardMessageByStep, map);
}