I’m currently experimenting to see if sendChatMsg is functioning correctly. Specifically, I’m attempting to echo the message back within MeetingChatCtrlEvent::onChatMsgNotification. In this function, at line auto e = chatController_->SendChatMsgTo(msgBuilder->Build());, SendChatMsgTo fails with varying error values across different runs. The chat window shows nothing, although receiving messages works fine. Any thoughts on what might be causing this?
SendMsgTo was called in
onChatMsgNotification. Verified the sendMsgTo was called in main thread. Updated zoom SDK to 6.0.10.5355. The same code worked fine. Is it possible the latest SDK would have the failure ?
I’ve just tried this and it works, however I’m a different implementation to make sure that the sending of message will be definitely in the main thread.
//onChatMessageReceived is a helper method in the main thread, which is passed into this event listener. When there is message received on the event listener, it passes the message back into onChatMessageReceived method in the main thread.
MeetingChatEventListener::MeetingChatEventListener(void(*onChatMessageReceived)(IChatMsgInfo* chatMsg))
{
onChatMessageReceived_ = onChatMessageReceived;
}
void MeetingChatEventListener::onChatMsgNotifcation(IChatMsgInfo* chatMsg, const zchar_t* content)
{
std::cout<<"onChatMsgNotifcation: " << chatMsg->GetSenderDisplayName() << " says " << chatMsg->GetContent() << endl;
if (onChatMessageReceived_)onChatMessageReceived_(chatMsg);
}
.
.
.
//in the main thread
//callback when given receive messages
void onChatMessageReceived(IChatMsgInfo* chatMsg) {
printf("onChatMessageReceived\n");
IMeetingChatController* meetingchatcontroller = m_pMeetingService->GetMeetingChatController();
// Convert std::wstring to std::string (UTF-8)
std::wstring wstr = L"Reply to user!";
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
std::string str = converter.to_bytes(wstr);
// Ensure zchar_t is defined as char if not already defined
typedef char zchar_t;
char charArray[1024]; // Choose an appropriate size
std::strncpy(charArray, str.c_str(), sizeof(charArray));
// Ensure null-termination
charArray[sizeof(charArray) / sizeof(charArray[0]) - 1] = '\0';
const zchar_t* constCharArray = charArray;
IChatMsgInfoBuilder* chatbuilder = meetingchatcontroller->GetChatMessageBuilder();
chatbuilder->SetReceiver(0);
chatbuilder->SetMessageType(SDKChatMessageType_To_All);
chatbuilder->SetContent(constCharArray);
chatbuilder->Build();
meetingchatcontroller->SendChatMsgTo(chatbuilder->Build());
}
@chunsiong.zoom
I’ve confirmed that my code executes in the main thread. Upon review, v6.0.12.5551 functions correctly for me, while v6.1.0.225 does not. However, v6.1.1.493 also works as expected. Since the most recent SDK version resolves the issues, I have no further concerns. Thank you for the follow-up.