votePoll method

Future<PollVoteEvent> votePoll(
  1. {required int pollId,
  2. required List<int> pollOptionIds}
)

Vote on pollOptionIds. This operation overrides previous vote actions, so to update previous vote, pass new pollOptionIds as parameter. To cancel votes, pass an empty list as pollOptionIds.

Implementation

Future<PollVoteEvent> votePoll({
  required int pollId,
  required List<int> pollOptionIds,
}) async {
  sbLog.i(
      StackTrace.current, 'pollId: $pollId, pollOptionIds: $pollOptionIds');

  final cmd = Command.buildVotePoll(
    channelType: channelType,
    channelUrl: channelUrl,
    pollId: pollId,
    pollOptionIds: pollOptionIds,
  );

  var result = await chat.commandManager.sendCommand(cmd);
  if (result != null) {
    return PollVoteEvent.fromJson(result.payload);
  } else {
    throw WebSocketFailedException();
  }
}