Configuration options
Sync functions and connection state
This hook handles real-time synchronization of poll state across all participants in a room using the Hiyve data message system.
Message Flow:
Owner Responsibilities:
function PollsWithSync() {
const pollsRef = useRef(new Map());
const userVotesRef = useRef(new Map());
const {
createPoll,
startPoll,
endPoll,
castVote,
connected,
} = usePollSync({
isOwner,
localUserId: userId,
localUserName: userName,
pollsRef,
userVotesRef,
onStateUpdate: setPolls,
});
const handleCreate = (pollData) => {
const poll = createPoll(pollData);
if (poll) {
setPolls(prev => [...prev, poll]);
}
};
}
Hook for poll synchronization via data messages.