Represents a call in the system.
예제 #1
0
 /// <summary>
 /// Hunt for destination.
 /// </summary>
 /// <param name="request"></param>
 /// <param name="call"></param>
 private void LookupDestination(IRequest request, Call call)
 {
     Registration reg = _registrar.Get(request.To);
     if (reg == null)
     {
         call.Destination = new CallParty {Contact = request.To, IsInternal = false};
         call.Origin = call.Origin | CallOrigins.Outbound;
         return;
     }
     call.Destination = new CallParty {Contact = reg.Contacts[0], IsInternal = true};
     call.Origin = call.Origin | CallOrigins.Inbound;
 }
예제 #2
0
        private void LookupCaller(IRequest request, Call call)
        {
            Registration reg = _registrar.Get(request.From);
            if (reg == null)
            {
                call.Origin = CallOrigins.External;
                call.Caller = new CallParty {Contact = request.From, IsInternal = false};
                return;
            }

            call.Id = request.CallId;
            call.Origin = CallOrigins.Internal;
            call.Caller = new CallParty {Contact = reg.Contacts[0], IsInternal = true};
        }
예제 #3
0
        private void TriggerCallFiltering(Call call, RequestContext context)
        {
            try
            {
                CallFiltering(this, new CallEventArgs(call));
            }
            catch (Exception err)
            {
                if (err is SipException)
                {
                    var exception = (SipException) err;
                    IResponse response = context.Request.CreateResponse(exception.StatusCode, exception.Message);
                    context.Transaction.Send(response);
                }

                //Unhandled exception logger.
            }
        }
예제 #4
0
        public Call Call(Contact from, Contact to)
        {
            IRequest request = _stack.CreateRequest(SipMethod.INVITE, from, to);
            IClientTransaction transaction = _stack.Send(request);
            transaction.ResponseReceived += OnResponse;
            transaction.TimedOut += OnTimeout;
            transaction.TransportFailed += OnTransportFailed;
            transaction.Terminated += OnTerminate;

            var call = new Call
                           {
                               Destination = new CallParty {Contact = to},
                               Caller = new CallParty {Contact = from},
                               Id = request.CallId,
                               Reason = CallReasons.Direct,
                               State = CallState.Proceeding
                           };
            _calls.Add(call.Id, call);
            CallChanged(this, new CallEventArgs(call));
            return call;
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CallEventArgs"/> class.
 /// </summary>
 /// <param name="call">The call.</param>
 public CallEventArgs(Call call)
 {
     Call = call;
 }
예제 #6
0
 private Call CreateCall(IRequest request)
 {
     var call = new Call {State = CallState.Proceeding, Reason = CallReasons.Direct};
     return call;
 }