Hi @Carson_Chen,
Here’s a code sample. I commented what works and what doesn’t. I guess it might have something to do with threads. I suspect the socket’s callbacks are happening in another thread, but I’m not sure:
using Quobject.SocketIoClientDotNet.Client;
namespace zoom_sdk_demo
{
public partial class start_join_meeting : Window
{
const string staysafeButtonServerEndpoint = "https://myserver";
IMeetingServiceDotNetWrap meetingService = ZOOM_SDK_DOTNET_WRAP.CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap();
IMeetingParticipantsControllerDotNetWrap participantsController = ZOOM_SDK_DOTNET_WRAP.CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController();
IMeetingVideoControllerDotNetWrap videoController = ZOOM_SDK_DOTNET_WRAP.CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingVideoController();
IMeetingChatControllerDotNetWrap chatController = ZOOM_SDK_DOTNET_WRAP.CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingChatController();
Socket socket = IO.Socket(staysafeButtonServerEndpoint);
uint userInSpotlight = 0;
public start_join_meeting()
{
RegisterCallBack();
initSocketIO();
InitializeComponent();
}
public void initSocketIO()
{
socket.On(Socket.EVENT_CONNECT, () =>
{
Console.WriteLine("Connected to socket.io server, sending hello.");
socket.Emit("room", "zoom");
});
socket.On("SpotlightVideo", (data) =>
{
Console.WriteLine("> socketio got 'SpotlightVideo'");
if (meetingService.GetMeetingStatus() != MeetingStatus.MEETING_STATUS_INMEETING) { Console.WriteLine("> not in meeting"); return; }
uint userId = (uint)Convert.ToInt32(data);
Console.WriteLine("SpotlightVideo " + userId);
videoController.SpotlightVideo(true, userId); // THIS WORKS
});
socket.On("SendChatTo", (data) =>
{
if (meetingService.GetMeetingStatus() != MeetingStatus.MEETING_STATUS_INMEETING) { Console.WriteLine("> not in meeting"); return; }
var dataObject = (JObject)data;
uint userId = (uint)Convert.ToInt32(dataObject["userId"]);
string text = (string)dataObject["text"];
chatController.SendChatTo(userId, text); // THIS DOESN'T WORK
});
}
public void onUserJoin(Array userIds)
{
if (null == (Object)userIds) return;
foreach (uint userId in userIds)
{
var user = participantsController.GetUserByUserID(userId);
chatController.SendChatTo(userId, "Welcome " + user.GetUserNameW()); // THIS WORKS
}
}
}
}