updateUserMessage method

Future<UserMessage> updateUserMessage(
  1. int messageId,
  2. UserMessageParams params
)

Updates UserMessage on this channel with messageId and params.

Implementation

Future<UserMessage> updateUserMessage(
    int messageId, UserMessageParams params) async {
  if (messageId <= 0) {
    throw InvalidParameterError();
  }

  final cmd = Command.buildUpdateUserMessage(
    channelUrl,
    messageId,
    params,
  );

  try {
    final res = await _sdk.cmdManager.sendCommand(cmd);
    if (res != null) {
      return BaseMessage.msgFromJson<UserMessage>(
        res.payload,
        type: cmd.cmd,
      )!; //mark!
    } else {
      logger.e('failed to update user message');
      throw WebSocketError();
    }
  } catch (e) {
    rethrow;
  }
}