Chat
What's a video call without being able to send messages to each other too? 100ms supports chat for every video/audio room you create.
Sending Chat Messages
There are multiple types of messages that can be sent - Broadcast, Group, Direct Messages
Broadcast Message:
This will be received by everyone in the room
hmsActions.sendBroadcastMessage("hello everyone!"); // yes it's that simple 😉
Group Message:
At the moment, we support sending messages across roles.
hmsActions.sendGroupMessage("hello everyone!", ['role1', 'role2']); // yes it's that simple 😉
Direct Message:
This will be received by selected peer in the room
hmsActions.sendDirectMessage("hello everyone!", selectPeer.id); // yes it's that simple 😉
Showing all the messages
You can access all messages using the selector selectHMSMessages
.
import { selectHMSMessages, selectMessagesByRole, selectMessagesByPeerID, selectBroadcastMessages, selectBroadcastMessagesUnreadCount, selectMessagesUnreadCountByRole, selectMessagesUnreadCountByPeerID, selectUnreadHMSMessagesCount, } from '@100mslive/hms-video-store'; function renderMessages(messages) { console.log("messages - ", messages); } hmsStore.subscribe(renderMessages, selectHMSMessages); // get all messages hmsStore.subscribe(renderMessages, selectMessagesByRole('role1')); //get messages by role hmsStore.subscribe(renderMessages, selectMessagesByPeerID(selectPeer.id)); // get messages by peer hmsStore.subscribe(renderMessages, selectBroadcastMessages); // get only broadcast messages // You can get unread counts by the following selectors function unreadCount(count) { console.log('unreadcount - ', count); } hmsStore.subscribe(unreadCount, selectUnreadHMSMessagesCount); // all messages unread count hmsStore.subscribe(unreadCount, selectBroadcastMessagesUnreadCount); // broadcast unread count hmsStore.subscribe(unreadCount, selectMessagesUnreadCountByRole('role1')); // role unread count hmsStore.subscribe(unreadCount, selectMessagesUnreadCountByPeerID(selectPeer.id)); // peer unread count