/// <summary>
 /// Checks the call API invocation's result is OK.
 /// </summary>
 public static void CheckOk(this CallError callError)
 {
     if (callError != CallError.OK)
     {
         throw new InvalidOperationException("Call error: " + callError);
     }
 }
Exemple #2
0
        //internal void InternalSendRinging()
        //{
        //    _ringingRetransmit = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(5)).Subscribe((i) =>
        //    {
        //        if (_ringingResponse == null)
        //        {
        //            _ringingResponse = _inviteRequest.CreateResponse(SipResponseCodes.x180_Ringing);
        //            _ringingResponse.To.Tag = SipUtil.CreateTag();
        //            var contactUri = _addressFactory.CreateUri("", _provider.ListeningPoint.ToString());
        //            _ringingResponse.Contacts.Add(_headerFactory.CreateContactHeader(contactUri));
        //            _inviteTransaction = (SipInviteServerTransaction)_provider.CreateServerTransaction(_inviteRequest);
        //            _dialog = _provider.CreateServerDialog(_inviteTransaction);
        //            _inviteTransaction.SendResponse(_ringingResponse);
        //        }
        //        else
        //        {
        //            _inviteTransaction.SendResponse(_ringingResponse);
        //        }
        //    });
        //}

        public void RaiseCallErrorOccured(CallError error, string message = null)
        {
            CallErrorOccured(this, new VoipEventArgs <CallErrorObject>(new CallErrorObject()
            {
                Type = error, Message = message
            }));
        }
Exemple #3
0
 /// <summary>
 /// 错误信息
 /// </summary>
 /// <param name="callError"></param>
 public void Notify(CallError callError)
 {
     _innerListener.Push(callError);
 }
Exemple #4
0
 /// <summary>
 /// Checks the call API invocation's result is OK.
 /// </summary>
 public static void CheckOk(this CallError callError)
 {
     GrpcPreconditions.CheckState(callError == CallError.OK, "Call error: " + callError);
 }
        /// <summary>
        /// 调用事件信息
        /// </summary>
        /// <param name="callArgs"></param>
        public void Notify(CallEventArgs callArgs)
        {
            if (_listeners.Count == 0)
            {
                return;
            }

            MessageListener[] listeners = _listeners.ToArray();
            foreach (MessageListener lstn in listeners)
            {
                try
                {
                    if ((lstn.Apps.Count == 0 || lstn.Apps.Any(p => string.Compare(p, callArgs.Caller.AppName, true) == 0)) &&
                        (lstn.Types.Count == 0 || lstn.Types.Any(p => string.Compare(p, callArgs.Caller.ServiceName, true) == 0)))
                    {
                        var options = lstn.Options;
                        if (options.PushCallError && callArgs.IsError)
                        {
                            var callError = new CallError
                            {
                                Caller    = callArgs.Caller,
                                Message   = callArgs.Error.Message,
                                Error     = ErrorHelper.GetErrorWithoutHtml(callArgs.Error),
                                HtmlError = ErrorHelper.GetHtmlError(callArgs.Error)
                            };

                            lstn.Notify(callError);
                        }

                        if (options.PushCallTimeout && !callArgs.IsError)
                        {
                            //如果设定的时间不正确,不进行推送
                            if (options.CallTimeout <= 0 &&
                                options.CallRowCount <= 0)
                            {
                                continue;
                            }

                            if (callArgs.ElapsedTime > options.CallTimeout * 1000 ||
                                callArgs.Count > options.CallRowCount)
                            {
                                var callTimeout = new CallTimeout
                                {
                                    Caller      = callArgs.Caller,
                                    Count       = callArgs.Count,
                                    ElapsedTime = callArgs.ElapsedTime
                                };

                                lstn.Notify(callTimeout);
                            }
                        }
                    }
                }
                catch (SocketException ex)
                {
                    RemoveListener(lstn);
                }
                catch (Exception ex)
                {
                    if (OnError != null)
                    {
                        OnError(ex);
                    }
                }
            }
        }
Exemple #6
0
        //internal void InternalSendRinging()
        //{
        //    _ringingRetransmit = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(5)).Subscribe((i) =>
        //    {
        //        if (_ringingResponse == null)
        //        {
        //            _ringingResponse = _inviteRequest.CreateResponse(SipResponseCodes.x180_Ringing);
        //            _ringingResponse.To.Tag = SipUtil.CreateTag();
        //            var contactUri = _addressFactory.CreateUri("", _provider.ListeningPoint.ToString());
        //            _ringingResponse.Contacts.Add(_headerFactory.CreateContactHeader(contactUri));
        //            _inviteTransaction = (SipInviteServerTransaction)_provider.CreateServerTransaction(_inviteRequest);
        //            _dialog = _provider.CreateServerDialog(_inviteTransaction);
        //            _inviteTransaction.SendResponse(_ringingResponse);
        //        }
        //        else
        //        {
        //            _inviteTransaction.SendResponse(_ringingResponse);
        //        }
        //    });
        //}

        public void RaiseCallErrorOccured(CallError error, string message = null)
        {
            CallErrorOccured(this, new VoipEventArgs<CallErrorObject>(new CallErrorObject() {Type = error, Message = message }));
        }