public void Call(SIPCallDescriptor sipCallDescriptor) { try { m_uacCallDescriptor = sipCallDescriptor; SIPRequest uacInviteRequest = GetInviteRequest(m_uacCallDescriptor.Uri, sipCallDescriptor); if (sipCallDescriptor.MangleResponseSDP && sipCallDescriptor.MangleIPAddress != null) { uacInviteRequest.Header.ProxyReceivedFrom = sipCallDescriptor.MangleIPAddress.ToString(); } uacInviteRequest.Body = sipCallDescriptor.Content; uacInviteRequest.Header.ContentType = sipCallDescriptor.ContentType; uacInviteRequest.LocalSIPEndPoint = m_blackhole; uacInviteRequest.RemoteSIPEndPoint = m_blackhole; // Now that we have a destination socket create a new UAC transaction for forwarded leg of the call. m_uacTransaction = m_sipTransport.CreateUACTransaction(uacInviteRequest, m_blackhole, m_blackhole, null); if (m_uacTransaction.CDR != null) { m_uacTransaction.CDR.Owner = m_uacOwner; m_uacTransaction.CDR.AdminMemberId = m_uacAdminMemberId; m_uacTransaction.CDR.DialPlanContextID = (m_uacCallDescriptor != null) ? m_uacCallDescriptor.DialPlanContextID : Guid.Empty; } //uacTransaction.UACInviteTransactionInformationResponseReceived += ServerInformationResponseReceived; //uacTransaction.UACInviteTransactionFinalResponseReceived += ServerFinalResponseReceived; //uacTransaction.UACInviteTransactionTimedOut += ServerTimedOut; //uacTransaction.TransactionTraceMessage += TransactionTraceMessage; m_uacTransaction.SendInviteRequest(m_blackhole, m_uacTransaction.TransactionRequest); SIPRequest uasInviteRequest = uacInviteRequest.Copy(); uasInviteRequest.LocalSIPEndPoint = m_blackhole; uasInviteRequest.RemoteSIPEndPoint = m_blackhole; uasInviteRequest.Header.Vias.TopViaHeader.Branch = CallProperties.CreateBranchId(); m_uasTransaction = m_sipTransport.CreateUASTransaction(uasInviteRequest, m_blackhole, m_blackhole, null); SetOwner(sipCallDescriptor.ToSIPAccount.Owner, sipCallDescriptor.ToSIPAccount.AdminMemberId); //m_uasTransaction.TransactionTraceMessage += TransactionTraceMessage; //m_uasTransaction.UASInviteTransactionTimedOut += ClientTimedOut; //m_uasTransaction.UASInviteTransactionCancelled += (t) => { }; QueueNewCall_External(this); CallTrying.Invoke(this, null); } catch (Exception excp) { logger.Error("Exception SIPB2BUserAgent Call. " + excp.Message); } }
public SIPRequest Call(SIPCallDescriptor sipCallDescriptor, SIPEndPoint serverEndPoint) { m_uacCallDescriptor = sipCallDescriptor; m_uac = new SIPClientUserAgent(m_sipTransport, m_outboundProxy); m_uac.CallFailed += ClientCallFailed; m_uac.CallTrying += (uac, resp) => CallTrying?.Invoke(uac, resp); m_uac.CallRinging += (uac, resp) => CallRinging?.Invoke(uac, resp); m_uac.CallAnswered += ClientCallAnswered; return(m_uac.Call(m_uacCallDescriptor)); }
private Task <SocketError> ServerInformationResponseReceived(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPTransaction sipTransaction, SIPResponse sipResponse) { logger.LogDebug("Information response " + sipResponse.StatusCode + " " + sipResponse.ReasonPhrase + " for " + m_serverTransaction.TransactionRequest.URI.ToString() + "."); if (m_callCancelled) { // Call was cancelled in the interim. Cancel(); } else { if (sipResponse.Status == SIPResponseStatusCodesEnum.Ringing || sipResponse.Status == SIPResponseStatusCodesEnum.SessionProgress) { CallRinging?.Invoke(this, sipResponse); } else { CallTrying?.Invoke(this, sipResponse); } } return(Task.FromResult(SocketError.Success)); }