예제 #1
0
        static void Main(string[] args)
        {
            client.InitializeConnection();
            client.InitializeVideoRoomConnection();
            client.CreateRoom(100);
            JanusVideoRoomExistsResponse existResponse = client.RoomExists(100);
            JanusVideoRoomListResponse   listResponse  = client.ListRooms();

            client.RemoveRoom(100);
            client.CleanUp();
        }
예제 #2
0
 /// <summary>
 /// This is part of the synchronous responses that the video room plugin provides
 /// </summary>
 /// <returns>A class containing the list of video rooms</returns>
 public JanusVideoRoomListResponse ListRooms()
 {
     if (janus_video_plugin_ref.IncRef())
     {
         if (!IsRestClientInitialized())
         {
             var resp = new JanusVideoRoomListResponse
             {
                 janus      = "failure",
                 plugindata = new JanusVideoRoomListPluginData
                 {
                     plugin = "janus.plugin.videoroom",
                     data   = new JanusVideoRoomListPluginDataInternal
                     {
                         videoroom  = "none",
                         list       = null,
                         error_code = (int)JanusRoomErrorCodes.JANUS_VIDEOROOM_ERROR_NO_SESSION,
                         error      = "Initialize the API client first"
                     }
                 }
             };
             janus_video_plugin_ref.DecRef();
             return(resp);
         }
         if (!InitializeVideoRoomConnection())
         {
             var resp = new JanusVideoRoomListResponse
             {
                 janus      = "failure",
                 plugindata = new JanusVideoRoomListPluginData
                 {
                     plugin = "janus.plugin.videoroom",
                     data   = new JanusVideoRoomListPluginDataInternal
                     {
                         videoroom  = "none",
                         list       = null,
                         error_code = (int)JanusRoomErrorCodes.JANUS_VIDEOROOM_ERROR_NO_SESSION,
                         error      = "Could not attach the plugin"
                     }
                 }
             };
             janus_video_plugin_ref.DecRef();
             return(resp);
         }
         var room_request = new RestRequest(Method.POST);
         room_request.Resource      = "{SessionToken}/" + JanusVideoRoomPluginHandle;
         room_request.RequestFormat = DataFormat.Json;
         dynamic obj = new ExpandoObject();
         obj.request = "list";
         dynamic msg = new ExpandoObject();
         if (api_secret.HasValue())
         {
             msg.apisecret = api_secret;
         }
         msg.janus       = "message";
         msg.transaction = GetNewRandomTransaction();
         msg.body        = obj;
         room_request.AddBody(msg);
         JanusVideoRoomListResponse response = Execute <JanusVideoRoomListResponse>(room_request);
         if (response != null)
         {
             delay_timeout.ResetDelay(29);
         }
         janus_video_plugin_ref.DecRef();
         return(response);
     }
     return(null);
 }