Manage chat messages
Read message details, delete messages, and manage host chat privileges. For sending and receiving messages, see Core features.
Read message metadata
Each message you receive in onChatNewMessageNotify is an IZoomVideoSDKChatMessage. Use its accessors to read the message details.
messageItem->getContent(); // The message text.
messageItem->getSendUser(); // The sender.
messageItem->getReceiveUser(); // The recipient of a private message.
messageItem->getMessageID(); // The unique ID of the message.
messageItem->getTimeStamp(); // The time the message was sent.
messageItem->isChatToAll(); // false for private messages.
messageItem->isSelfSend(); // true if the local user sent the message.
Delete a chat message
To delete a message, pass its ID to deleteChatMessage. Check canChatMessageBeDeleted first, since whether a message can be deleted depends on the local user's privileges and the message age.
IZoomVideoSDKChatHelper* pChatHelper = m_pVideoSDK->getChatHelper();
if (pChatHelper->canChatMessageBeDeleted(msgID)) {
pChatHelper->deleteChatMessage(msgID);
}
Listen for deletions
When a message is deleted, the SDK calls onChatMsgDeleteNotification with the deleted message's ID and who deleted it.
void CExampleListener::onChatMsgDeleteNotification(IZoomVideoSDKChatHelper* pChatHelper, const zchar_t* msgID, ZoomVideoSDKChatMessageDeleteType deleteBy)
{
// Remove the message identified by msgID from your UI.
}
deleteBy is one of the following values.
| Value | Meaning |
|---|---|
ZoomVideoSDKChatDelete_None | No deletion. |
ZoomVideoSDKChatDelete_BySelf | The message was deleted by the user who sent it. |
ZoomVideoSDKChatDelete_ByHost | The message was deleted by the host. |
ZoomVideoSDKChatDelete_ByDlp | The message was removed automatically by data loss prevention (DLP). |
Host control: chat privileges
The host can control who participants are allowed to chat with by calling changeChatPrivilege. Read the current privilege with getChatPrivilege.
IZoomVideoSDKChatHelper* pChatHelper = m_pVideoSDK->getChatHelper();
// Allow participants to chat publicly only.
pChatHelper->changeChatPrivilege(ZoomVideoSDKChatPrivilege_Publicly);
changeChatPrivilege takes one of the following values.
| Value | Meaning |
|---|---|
ZoomVideoSDKChatPrivilege_Unknown | The privilege is not known. |
ZoomVideoSDKChatPrivilege_Publicly_And_Privately | Participants can chat with everyone and privately with individuals. |
ZoomVideoSDKChatPrivilege_No_One | Participants cannot chat with anyone. |
ZoomVideoSDKChatPrivilege_Publicly | Participants can chat with everyone, but not privately. |
To respond when the privilege changes, implement onChatPrivilegeChanged.
void CExampleListener::onChatPrivilegeChanged(IZoomVideoSDKChatHelper* pChatHelper, ZoomVideoSDKChatPrivilegeType privilege)
{
// Update your chat UI to reflect the new privilege.
}