SendChatTo() not working inside callback function

When I send a command via socket.io to my C# Zoom application, which then sends a chat using SendChatTo(), the SDK returns with error 15. If I’m correct, that’s SDKERR_INTELNAL_ERROR.

If do the exact same command when someone connects, no error.

When I execute other commands, like spotlightVideo() from a socket.io callback function, it also works.

What could be wrong?

Sam

Hi Sam,

Thanks for the post. We have not tested our C# wrapper with socket.io before, could you provide an example(maybe some code snippet or steps to reproduce would be really helpful) and what are the parameters you are passing to trigger the interface? We could look into this and further investigate and figure out why.

Thanks!

Hi @carson.zoom,

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
      }
    }
  }
}

Hi @sam.decrock,

Thanks for the reply and thanks for providing the code snippet. Based on the code, everything looks good so I am not sure why you are getting unexpected results. Would you mind providing an SDK log for us to further investigate? You may set the attribute enableLogByDefault = true at SDK initialization and find the SDK log in %appdata%/zoomsdk/logs/

Thanks!

Hi, thanks,
This is the log that shows up in the folder. I hope you guys can read it as it seems a bit encrypted if you ask me :wink:

Ok, I was able to fix it by wrapping my code using this method: https://stackoverflow.com/questions/11625208/accessing-ui-main-thread-safely-in-wpf

Application.Current.Dispatcher.Invoke(new Action(() => { // my code }));

For example:

Application.Current.Dispatcher.Invoke(new Action(() => {
    Console.WriteLine("SendChatTo " + userId + ": " + text);
    var ret = chatController.SendChatTo(userId, text);
    Console.WriteLine(ret);
}));

Hi @sam.decrock,

Thanks for the reply, the log, and the solution. Glad to hear that this issue has been resolved. :slight_smile: