Esempio n. 1
0
        /// <summary>
        /// 创建一个rtp能力可以识别的消息
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="header"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        private Message CreateResponseMessage(string eventName, DTObject header, byte[] content, string error, bool isCompleted)
        {
            var rtpData = new RtpData(this.Data.Participant, header, content);
            var data    = RtpDataAnalyzer.Serialize(rtpData);
            var msg     = RtpCapability.CreateCallMessage(this.Name, eventName, data, this.RequestId, (mh) =>
            {
                if (!string.IsNullOrEmpty(this.Destination))
                {
                    mh.SetValue(MessageField.Destination, this.Destination);
                }
                else if (this.Destinations != null)
                {
                    mh.SetValue(MessageField.Destinations, this.Destinations);
                }

                if (!string.IsNullOrEmpty(error))
                {
                    mh.SetValue(RtpCapability.FieldRtpCallErrorMessage, error);
                }
                mh.SetValue(RtpCapability.FieldRtpCallIsCompleted, isCompleted);
            });

            msg.Origin = this.Data.Participant.Orgin;
            return(msg);
        }
Esempio n. 2
0
 /// <summary>
 /// 用该方法注册能力,会自动卸载
 /// </summary>
 /// <param name="capability"></param>
 protected void RegisterCapability(RtpCapability capability)
 {
     if (_channel != null)
     {
         _channel.RegisterCapability(capability); //切换会议的能力
         _capabilities.Add(capability);
     }
 }
Esempio n. 3
0
 internal void Process(ClientEvents.MessageReceivedEventArgs ea)
 {
     RtpCapability.Process(this.Context.Client, ea); //新版本中处理消息,统一用能力事件
     //var capabilityName = RtpCapability.GetCapabilityName(ea.Message);
     //var capability = GetCapability(capabilityName);
     ////if (capability == null) throw new ApplicationException("在地址" + this.Address + "的rtp通道上没有给予名称为" + capabilityName + "的能力");
     //if (capability == null) return; //这代表虽然加入了该地址,但是并不需要这个能力,不予处理
     //capability.Process(ea);
 }
Esempio n. 4
0
 private void LogoutCapability(RtpCapability capability)
 {
     if (capability != null)
     {
         capability.Leave();
         _capabilities.Remove(capability);
         capability.Dispose();
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 注册Capability,请保证每个Capability是线程安全的
 /// </summary>
 /// <param name="finder"></param>
 public void RegisterCapability(RtpCapability capability)
 {
     lock (_capabilities)
     {
         var exist = GetCapability(capability.Name) != null;
         if (!exist)
         {
             capability.Join(this);
             _capabilities.Add(capability);
         }
     }
 }
Esempio n. 6
0
        private RtpCapability GetCapability(string capabilityName)
        {
            RtpCapability result = null;

            lock (_capabilities)
            {
                foreach (var capability in _capabilities)
                {
                    if (capability.Name == capabilityName)
                    {
                        result = capability;
                        break;
                    }
                }
            }
            return(result);
        }