Introduction
The meetings polls object can be accessed using meeting.polls
. It provides
methods to create polls, vote, and more.
meeting.polls.items
returns an array of all polls created in a meeting,
where each element is an object of type Poll
.
class Poll {
final String id;
final String question;
final bool anonymous;
final bool hideVotes;
final String createdBy;
final List<PollOption> options;
final List<String> voted;
}
The Poll
class has the following properties:
id
: Unique ID assigned to each poll.question
: Question of the poll.anonymous
: To hide the votes of each user even after completion. (false by default)hideVotes
: Hide votes until the voting is complete. (enabled if anonymous is enabled)createdBy
: Name of creator the poll.options
: Array ofPollOption
object, contains all the options to the poll question.voted
: Array of String which contains User IDs that have voted.
The type Poll
represents a poll in a RealtimeKit meeting. It also
contains list of PollOption
which are options for a given poll. And every
PollOption
has list of votes inside of it. Votes are objects of class
PollVote
which internally has id and name of the vote.
class PollOption(
final String text; // Option text.
final List<PollVote> votes; // List of votes.
final int count; // Number of votes.
);
class PollVote {
final String id; // ID of the voter.
final String name; // Name of the voter.
}
Listening to new polls in a meeting
To be able to receive new poll messages you need to implement a method
onPollUpdates()
method from callback RtkPollsEventListener
:
To get poll updates, listen to onPollUpdates()
callback:
class PollEventsListener extends RtkPollsEventListener {
void onPollUpdates(List<Poll> pollItems) {
/// code to handle polls
}
void onNewPoll(Poll poll) {
/// code to handle new poll
}
}
You can subscribe to these events as follows:
meeting.addPollsEventListener(PollEventsListener());