Skip to main content
Version: 0.0.x

Raise Hand - Javascript

This guide explains how PubSub can be used to implement the Raise Hand functionality. If you are not familiar with the PubSub mechanism and pubSub property of meeting object, you can follow this guide.

Implementing Raise Hand

  1. To implement this functionality, first create a Raise Hand button. When this button is clicked, publish a message with the topic RAISE_HAND.
let meeting;

// Initialize Meeting
meeting = VideoSDK.initMeeting({
// ...
});

const raiseHandBtn = document.getElementById("raiseHandBtn");
raiseHandBtn.addEventListener("click", () => {
const topic = "RAISE_HAND";

meeting?.pubSub.publish(topic, "Raise Hand");
});
  1. Next, alert all the speakers, displaying the identity of the participant who raised their hand.
let meeting;

// Initialize Meeting
meeting = VideoSDK.initMeeting({
// ...
});

// Callback function
function raiseHand(data) {
let { message, senderId, senderName, timestamp } = data;

if (meeting.localParticipant.mode == "CONFERENCE") {
window.alert(`${senderName} raise hand`);
}
}

meeting?.pubSub?.subscribe("RAISE_HAND", raiseHand);

API Reference

The API references for all the methods and events utilized in this guide are provided below.

Got a Question? Ask us on discord