Introduction
The meetings polls object can be accessed using rtkClient.polls
. It provides
methods to create polls, vote, and more.
rtkClient.polls.items
returns an array of all polls created in a meeting,
where each element is an object of type RtkPoll
.
class RtkPoll {
final String id;
final String question;
final bool anonymous;
final bool hideVotes;
final String createdBy;
final List<RtkPollOption> options;
final List<String> voted;
}
The RtkPoll
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 ofRtkPollOption
object, contains all the options to the poll question.
The type RtkPoll
represents a poll in a RealtimeKit meeting. It also
contains list of RtkPollOption
which are options for a given poll. And every
RtkPollOption
has list of votes inside of it. Votes are objects of class
RtkPollVote
which internally has id and name of the vote.
class RtkPollOption(
final String text; // Option text.
final List<RtkPollVote> votes; // List of votes.
final int count; // Number of votes.
);
class RtkPollVote {
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 PollEventsListeners extends RtkPollsEventListener {
void onPollUpdates(List<RtkPoll> polls) {
/// code to handle polls
}
void onNewPoll(RtkPoll poll) {
/// code to handle new poll
}
}
You can subscribe to these events as follows:
rtkClient.addPollEventsListener(PollEventsListeners());