getRemoteChatRoomHistoryMessages static method

Future<void> getRemoteChatRoomHistoryMessages(
  1. String targetId,
  2. int recordTime,
  3. int count,
  4. int order,
  5. dynamic finished(
    1. List? msgList,
    2. int? syncTime,
    3. int? code
    )?,
)

Implementation

static Future<void> getRemoteChatRoomHistoryMessages(String targetId, int recordTime, int count, int /*RCTimestampOrder*/ order, Function(List? /*<Message>*/ msgList, int? syncTime, int? code)? finished) async {
  Map map = {
    "targetId": targetId,
    "recordTime": recordTime,
    "count": count,
    "order": order,
  };
  Map resultMap = await _channel.invokeMethod(RCMethodKey.GetRemoteChatRoomHistoryMessages, map);
  int? code = resultMap["code"];
  int? syncTime = resultMap["syncTime"];
  if (code == 0) {
    List? msgStrList = resultMap["messages"];
    if (msgStrList == null) {
      if (finished != null) {
        finished(null, syncTime, code);
      }
      return;
    }
    List list = [];
    for (String msgStr in msgStrList) {
      Message? m = MessageFactory.instance!.string2Message(msgStr);
      list.add(m);
    }
    if (finished != null) {
      finished(list, syncTime, code);
    }
  } else {
    if (finished != null) {
      finished(null, syncTime, code);
    }
  }
}