IMeetingChatController::SendChatMsgTo fails

zoom-meeting-sdk-linux_x86_64-6.0.12.5551

Description

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?

This is the whole code block:

void MeetingChatCtrlEvent::onChatMsgNotifcation(IChatMsgInfo* chatMsg, const zchar_t* ) {
    auto msgBuilder=chatController_->GetChatMessageBuilder();
    msgBuilder->SetContent("Hello");
    msgBuilder->SetMessageType(SDKChatMessageType_To_All);
    msgBuilder->SetReceiver(0);
    msgBuilder->Build();
    auto e=chatController_->SendChatMsgTo(msgBuilder->Build());
    if(Zoom::hasError(e, "SendChatMsgTo failed:")) {
        return;
    }
}

@seungkoo I’ve just tried sending a chat message from the main thread and it works.

Are you trying to send a chat message from the onChatMsgNotification method itself?

	if (chatDemo) {
		IMeetingChatController* meetingchatcontroller= m_pMeetingService->GetMeetingChatController();
		meetingchatcontroller->SetEvent(new MeetingChatEventListener(&turnOnSendVideoAndAudio, &turnOffSendVideoandAudio));

		// Convert std::wstring to std::string (UTF-8)
		std::wstring wstr = L"Hello world!";
		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());



	}

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 ?

@seungkoo please tag me in your response, if not I’ll not get a notification.

Are you saying sending message worked in 6.0.1 and not working in 6.1.0 when called from onChatMsgNotification?

@chunsiong.zoom Yes that’s correct

@seungkoo

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.

1 Like