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