Ejemplo n.º 1
0
 /// <summary>
 /// 添加媒体服务器
 /// </summary>
 /// <param name="connectId"></param>
 public void AddMediaServe(string connectId)
 {
     lock (obj)
     {
         MediaServer mediaServer = new MediaServer();
         mediaServer.ConnectId = connectId;
         mediaServers.Add(mediaServer);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 发送媒体服务器,添加或是删除一个组(就是一个房间)
 /// </summary>
 /// <param name="media"></param>
 /// <param name="roomName"></param>
 /// <param name="bAdd"></param>
 private void Instance_OnMediaServerEvent(MediaServer media, string roomName, bool bAdd)
 {
     if (bAdd)
     {
         Clients.Client(media.ConnectId).AddRoom(roomName);
     }
     else
     {
         Clients.Client(media.ConnectId).RemoveRoom(roomName);
     }
 }
Ejemplo n.º 3
0
        private void OnMediaChange(MediaServer media, string roomName, bool bAdd)
        {
            var amessage = bAdd ? "添加" : "删除";

            LogHelper.LogMessage($"媒体服务器 {media.ConnectId} {amessage}房间 {roomName}");
            //OnMediaServerEvent?.Invoke(media, roomName, bAdd);
            if (bAdd)
            {
                MediaHub.Hub.Clients.Client(media.ConnectId).AddRoom(roomName);
            }
            else
            {
                MediaHub.Hub.Clients.Client(media.ConnectId).RemoveRoom(roomName);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 添加一个房间
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public Room AddRoom(string name)
 {
     lock (obj)
     {
         //查找媒体服务器里最适用的那一个
         if (mediaServers.Count <= 0)
         {
             LogHelper.LogMessage($"还没有任何媒体服务器添加进来,不能分配房间 {name}", OeipLogLevel.OEIP_ERROR);
             return(null);
         }
         Room room = new Room();
         room.Name   = name;
         room.Server = string.Empty;
         room.Port   = -1;
         rooms.Add(room);
         //在这逻辑先固定选第一台,后期根据实际情况来看
         MediaServer mediaServer = mediaServers[0];
         room.Media = mediaServer;
         //告诉媒体服务器端,需要添加一个房间供直播
         OnMediaChange(mediaServer, name, true);
         return(room);
     }
 }