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
.
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.
DytePollOption
has the following properties:
text
: Contains the option text.votes
: List ofDytePollVote
object, which contains info about voters of this option.count
: Int of number of votes given to this option.
DytePollVote
has the following properties:
id
: ID of the voter.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 this events by addPollEventsListener
method:
dyteClient.addPollEventsListener(PollEventsListeners());