sendChatroomCustomMessage method

Future<NIMResult<NIMChatroomMessage>> sendChatroomCustomMessage(
  1. {required String roomId,
  2. NIMMessageAttachment? attachment,
  3. bool resend = false,
  4. ChatroomMessageAction? action}
)

发送聊天室自定义消息

Implementation

Future<NIMResult<NIMChatroomMessage>> sendChatroomCustomMessage({
  required String roomId,
  NIMMessageAttachment? attachment,
  bool resend = false,
  ChatroomMessageAction? action,
}) async {
  return _createMessage({
    'roomId': roomId,
    'attachment': attachment?.toMap(),
    'messageType': 'custom',
  }).then((messageResult) async {
    if (messageResult.isSuccess) {
      final message = messageResult.data as NIMChatroomMessage;
      await action?.call(message);
      return sendChatroomMessage(message, resend);
    } else {
      return messageResult;
    }
  });
}