resendUserMessage method

UserMessage resendUserMessage(
  1. UserMessage message, {
  2. OnUserMessageCallback? onCompleted,
})

Resends failed UserMessage on this channel with message.

It returns UserMessage with MessageSendingStatus.pending and onCompleted will be invoked once the message has been sent completely. Channel event ChannelEventHandler.onMessageReceived will be invoked on all other members' end. NOTE that the pending message does not have a messageId.

Implementation

UserMessage resendUserMessage(
  UserMessage message, {
  OnUserMessageCallback? onCompleted,
}) {
  if (message.sendingStatus != MessageSendingStatus.failed) {
    throw InvalidParameterError();
  }
  if (message.channelUrl != channelUrl) {
    throw InvalidParameterError();
  }
  if (!message.isResendable()) {
    throw InvalidParameterError();
  }

  final params = UserMessageParams.withMessage(message, deepCopy: false);
  return sendUserMessage(
    params,
    onCompleted: onCompleted,
  );
}