Send Messages - React
Whenever any participant wants to notify other participants via chat messages or Raise hand, they can simply do it with VideoSDK Meeting.
This guide will provide an overview of how to implement chat and raise hand in a meeting.
-
Chat Message - If a participant wants to inform or notify something in current meeting, they can use
publish()
function of theusePubSub
hook and using the topicCHAT
. -
Raised Hand - If a participant has some doubts during the meeting and wants to raise hand, they can use
publish()
function of theusePubSub
hook and using the topicRAISED_HAND
.
note
publish()
function only takes string as an argument.
Send Message​
// importing usePubSub hook from react-sdk
import { usePubSub } from "@videosdk.live/react-sdk";
const MeetingView = () => {
// destructure publish method from usePubSub hook
const { publish, messages } = usePubSub("CHAT");
const onPress = () => {
// Sending Message
const message = "Hello Everyone!";
publish(message, { persist: true });
};
return <>...</>;
};
Raise Hand​
// importing usePubSub hook from react-sdk
import { usePubSub } from "@videosdk.live/react-sdk";
const MeetingView = () => {
// destructure publish method from usePubSub hook
const { publish, messages } = usePubSub("RAISE_HAND");
const onPress = () => {
// RAISE HAND
const message = "";
publish(message, { persist: true });
};
return <>...</>;
};
Events​
- onMessageReceived -
onMessageReceived
event will be triggered when a new message is published for the subscribed topic with the message object.
note
Check a detailed description of PubSub here.
Got a Question? Ask us on discord