コード例 #1
0
ファイル: Program.cs プロジェクト: stumct-sa/JanusSharp
        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>
 /// Returns true if the given room id exists and is created already in the janus gateway
 /// video server plugin.
 /// </summary>
 /// <param name="room_id">The room id to with which to check existance</param>
 /// <returns>True if exists, false otherwise</returns>
 public JanusVideoRoomExistsResponse RoomExists(int room_id)
 {
     if (janus_video_plugin_ref.IncRef())
     {
         if (!IsRestClientInitialized())
         {
             var resp = new JanusVideoRoomExistsResponse
             {
                 janus      = "failure",
                 plugindata = new JanusVideoRoomExistsPluginData
                 {
                     plugin = "janus.plugin.videoroom",
                     data   = new JanusVideoRoomExistsPluginDataInternal
                     {
                         videoroom  = "none",
                         exists     = false,
                         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 JanusVideoRoomExistsResponse
             {
                 janus      = "failure",
                 plugindata = new JanusVideoRoomExistsPluginData
                 {
                     plugin = "janus.plugin.videoroom",
                     data   = new JanusVideoRoomExistsPluginDataInternal
                     {
                         videoroom  = "none",
                         exists     = false,
                         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 = "exists";
         obj.room    = room_id;
         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);
         JanusVideoRoomExistsResponse response = Execute <JanusVideoRoomExistsResponse>(room_request);
         janus_video_plugin_ref.DecRef();
         return(response);
     }
     return(null);
 }