/// <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; }
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}; }
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. } }
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; }
/// <summary> /// Initializes a new instance of the <see cref="CallEventArgs"/> class. /// </summary> /// <param name="call">The call.</param> public CallEventArgs(Call call) { Call = call; }
private Call CreateCall(IRequest request) { var call = new Call {State = CallState.Proceeding, Reason = CallReasons.Direct}; return call; }