/// <summary> /// An answer on a blind transfer means the remote end of the dialogue being replaced should be re-invited and then the replaced dialogue /// should be hungup. /// </summary> /// <param name="contentType"></param> /// <param name="body"></param> /// <param name="toTag"></param> /// <param name="answeredDialogue"></param> /// <param name="transferMode"></param> /// <returns></returns> public SIPDialogue Answer(string contentType, string body, string toTag, SIPDialogue answeredDialogue, SIPDialogueTransferModesEnum transferMode) { try { if (m_answered) { Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "A blind transfer received an answer on an already answered call, hanging up dialogue.", m_owner)); answeredDialogue.Hangup(m_sipTransport, m_outboundProxy); } else { m_answered = true; Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "A blind transfer received an answer.", m_owner)); UASStateChanged?.Invoke(this, SIPResponseStatusCodesEnum.Ok, null); BlindTransfer_External(m_dialogueToReplace, m_oppositeDialogue, answeredDialogue); } TransactionComplete.Invoke(this); return(null); } catch (Exception excp) { logger.Error("Exception SIPTransferServerUserAgent Answer. " + excp.Message); throw; } }
/// <summary> /// An answer on a blind transfer means the remote end of the dialogue being replaced should be re-invited and then the replaced dialogue /// should be hungup. /// </summary> /// <param name="contentType"></param> /// <param name="body"></param> /// <param name="toTag"></param> /// <param name="answeredDialogue"></param> /// <param name="transferMode"></param> /// <returns></returns> public SIPDialogue Answer(string contentType, string body, string toTag, SIPDialogue answeredDialogue, SIPDialogueTransferModesEnum transferMode) { try { if (m_answered) { answeredDialogue.Hangup(m_sipTransport, m_outboundProxy); } else { m_answered = true; UASStateChanged?.Invoke(this, SIPResponseStatusCodesEnum.Ok, null); BlindTransfer_External(m_dialogueToReplace, m_oppositeDialogue, answeredDialogue); } TransactionComplete.Invoke(this); return(null); } catch (Exception excp) { logger.Error("Exception SIPTransferServerUserAgent Answer. " + excp.Message); throw; } }
public void Reject(SIPResponseStatusCodesEnum rejectCode, string rejectReason, string[] customHeaders) { logger.Debug("SIPB2BUserAgent Reject."); UASStateChanged?.Invoke(this, rejectCode, rejectReason); SIPResponse uasfailureResponse = SIPTransport.GetResponse(m_uasTransaction.TransactionRequest, rejectCode, rejectReason); m_uasTransaction.SendFinalResponse(uasfailureResponse); SIPResponse uacfailureResponse = SIPTransport.GetResponse(m_uacTransaction.TransactionRequest, rejectCode, rejectReason); if (customHeaders != null && customHeaders.Length > 0) { foreach (string header in customHeaders) { uacfailureResponse.Header.UnknownHeaders.Add(header); } } m_uacTransaction.GotResponse(m_blackhole, m_blackhole, uacfailureResponse); CallAnswered(this, uacfailureResponse); CallFailed.Invoke(this, "failed"); }
public void Progress(SIPResponseStatusCodesEnum progressStatus, string reasonPhrase, string[] customHeaders, string progressContentType, string progressBody) { try { if (!IsUASAnswered) { if ((int)progressStatus >= 200) { Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "UAS call was passed an invalid response status of " + (int)progressStatus + ", ignoring.", m_owner)); } else { UASStateChanged?.Invoke(this, progressStatus, reasonPhrase); // Allow all Trying responses through as some may contain additional useful information on the call state for the caller. // Also if the response is a 183 Session Progress with audio forward it. if (m_uasTransaction.TransactionState == SIPTransactionStatesEnum.Proceeding && progressStatus != SIPResponseStatusCodesEnum.Trying && !(progressStatus == SIPResponseStatusCodesEnum.SessionProgress && progressBody != null)) { Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "UAS call ignoring progress response with status of " + (int)progressStatus + " as already in " + m_uasTransaction.TransactionState + ".", m_owner)); } else { Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "UAS call progressing with " + progressStatus + ".", m_owner)); SIPResponse progressResponse = SIPResponse.GetResponse(m_uasTransaction.TransactionRequest, progressStatus, reasonPhrase); if (progressResponse.Status != SIPResponseStatusCodesEnum.Trying) { progressResponse.Header.To.ToTag = m_uasTransaction.LocalTag; } if (!progressBody.IsNullOrBlank()) { progressResponse.Body = progressBody; progressResponse.Header.ContentType = progressContentType; progressResponse.Header.ContentLength = progressBody.Length; } if (customHeaders != null && customHeaders.Length > 0) { foreach (string header in customHeaders) { progressResponse.Header.UnknownHeaders.Add(header); } } m_uasTransaction.SendProvisionalResponse(progressResponse); } } } else { logger.LogWarning("SIPServerUserAgent Progress fired on already answered call."); } } catch (Exception excp) { logger.LogError("Exception SIPServerUserAgent Progress. " + excp.Message); } }
public SIPDialogue Answer(string contentType, string body, SIPDialogue answeredDialogue, SIPDialogueTransferModesEnum transferMode) { try { logger.Debug("SIPB2BUserAgent Answer."); m_sipDialogue = answeredDialogue; UASStateChanged?.Invoke(this, SIPResponseStatusCodesEnum.Ok, null); SIPResponse uasOkResponse = SIPTransport.GetResponse(m_uasTransaction.TransactionRequest, SIPResponseStatusCodesEnum.Ok, null); m_uasTransaction.SendFinalResponse(uasOkResponse); m_uasTransaction.ACKReceived(m_blackhole, m_blackhole, null); SIPResponse uacOkResponse = SIPTransport.GetResponse(m_uacTransaction.TransactionRequest, SIPResponseStatusCodesEnum.Ok, null); uacOkResponse.Header.Contact = new List <SIPContactHeader>() { new SIPContactHeader(null, new SIPURI(SIPSchemesEnum.sip, m_blackhole)) }; m_uacTransaction.GotResponse(m_blackhole, m_blackhole, uacOkResponse); uacOkResponse.Header.ContentType = contentType; if (!body.IsNullOrBlank()) { uacOkResponse.Body = body; uacOkResponse.Header.ContentLength = body.Length; } CallAnswered.Invoke(this, uacOkResponse); return(null); } catch (Exception excp) { logger.Error("Exception SIPB2BUSerAgent Answer. " + excp.Message); throw; } }
public void Reject(SIPResponseStatusCodesEnum failureStatus, string reasonPhrase, string[] customHeaders) { Logger.Logger.Warn("SIPTransferServerUserAgent Reject called with " + failureStatus + " " + reasonPhrase + "."); UASStateChanged?.Invoke(this, failureStatus, reasonPhrase); }
public void Progress(SIPResponseStatusCodesEnum progressStatus, string reasonPhrase, string[] customHeaders, string progressContentType, string progressBody) { UASStateChanged?.Invoke(this, progressStatus, reasonPhrase); if (progressBody != null) { // Re-invite the remote dialogue so that they can listen to some real progress tones. } }
public void Progress(SIPResponseStatusCodesEnum progressStatus, string reasonPhrase, string[] customHeaders, string progressContentType, string progressBody) { try { if (!IsUASAnswered) { if ((int)progressStatus >= 200) { } else { UASStateChanged?.Invoke(this, progressStatus, reasonPhrase); if (m_uasTransaction.TransactionState == SIPTransactionStatesEnum.Proceeding) { } else { SIPResponse uasProgressResponse = SIPTransport.GetResponse(m_uasTransaction.TransactionRequest, progressStatus, reasonPhrase); m_uasTransaction.SendInformationalResponse(uasProgressResponse); SIPResponse uacProgressResponse = SIPTransport.GetResponse(m_uacTransaction.TransactionRequest, progressStatus, reasonPhrase); if (!progressBody.IsNullOrBlank()) { uacProgressResponse.Body = progressBody; uacProgressResponse.Header.ContentType = progressContentType; } if (customHeaders != null && customHeaders.Length > 0) { foreach (string header in customHeaders) { uacProgressResponse.Header.UnknownHeaders.Add(header); } } m_uacTransaction.GotResponse(m_blackhole, m_blackhole, uacProgressResponse); CallRinging(this, uacProgressResponse); } } } else { logger.Warn("B2BUserAgent Progress fired on already answered call."); } } catch (Exception excp) { logger.Error("Exception B2BUserAgent Progress. " + excp.Message); } }
public void Progress(SIPResponseStatusCodesEnum progressStatus, string reasonPhrase, string[] customHeaders, string progressContentType, string progressBody) { try { if (!IsUASAnswered) { if ((int)progressStatus >= 200) { Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "B2BUA call was passed an invalid response status of " + (int)progressStatus + ", ignoring.", m_uacOwner)); } else { UASStateChanged?.Invoke(this, progressStatus, reasonPhrase); if (m_uasTransaction.TransactionState == SIPTransactionStatesEnum.Proceeding) { Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "B2BUA call ignoring progress response with status of " + (int)progressStatus + " as already in " + m_uasTransaction.TransactionState + ".", m_uacOwner)); } else { Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "B2BUA call progressing with " + progressStatus + ".", m_uacOwner)); SIPResponse uasProgressResponse = SIPTransport.GetResponse(m_uasTransaction.TransactionRequest, progressStatus, reasonPhrase); m_uasTransaction.SendInformationalResponse(uasProgressResponse); SIPResponse uacProgressResponse = SIPTransport.GetResponse(m_uacTransaction.TransactionRequest, progressStatus, reasonPhrase); if (!progressBody.IsNullOrBlank()) { uacProgressResponse.Body = progressBody; uacProgressResponse.Header.ContentType = progressContentType; } if (customHeaders != null && customHeaders.Length > 0) { foreach (string header in customHeaders) { uacProgressResponse.Header.UnknownHeaders.Add(header); } } m_uacTransaction.GotResponse(m_blackhole, m_blackhole, uacProgressResponse); CallRinging(this, uacProgressResponse); } } } else { logger.Warn("B2BUserAgent Progress fired on already answered call."); } } catch (Exception excp) { logger.Error("Exception B2BUserAgent Progress. " + excp.Message); } }
public SIPDialogue Answer(string contentType, string body, string toTag, SIPDialogue answeredDialogue, SIPDialogueTransferModesEnum transferMode, string[] customHeaders) { try { if (m_uasTransaction.TransactionFinalResponse != null) { Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "UAS Answer was called on an already answered call, ignoring.", m_owner)); return(null); } else { UASStateChanged?.Invoke(this, SIPResponseStatusCodesEnum.Ok, null); if (!toTag.IsNullOrBlank()) { m_uasTransaction.LocalTag = toTag; } SIPResponse okResponse = m_uasTransaction.GetOkResponse(contentType, body); if (body != null) { okResponse.Header.ContentType = contentType; okResponse.Header.ContentLength = body.Length; okResponse.Body = body; } if (customHeaders != null && customHeaders.Length > 0) { foreach (string header in customHeaders) { okResponse.Header.UnknownHeaders.Add(header); } } m_uasTransaction.SendFinalResponse(okResponse); SIPDialogue = new SIPDialogue(m_uasTransaction, m_owner, m_adminMemberId); SIPDialogue.TransferMode = transferMode; return(SIPDialogue); } } catch (Exception excp) { logger.LogError("Exception SIPServerUserAgent Answer. " + excp.Message); throw; } }
public void Reject(SIPResponseStatusCodesEnum failureStatus, string reasonPhrase, string[] customHeaders) { try { if (m_uasTransaction.TransactionFinalResponse == null) { if ((int)failureStatus < 400) { Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "UAS Reject was passed an invalid response status of " + (int)failureStatus + ", ignoring.", m_owner)); } else { UASStateChanged?.Invoke(this, failureStatus, reasonPhrase); string failureReason = (!reasonPhrase.IsNullOrBlank()) ? " and " + reasonPhrase : null; Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "UAS call failed with a response status of " + (int)failureStatus + failureReason + ".", m_owner)); SIPResponse failureResponse = SIPResponse.GetResponse(m_uasTransaction.TransactionRequest, failureStatus, reasonPhrase); if (customHeaders != null && customHeaders.Length > 0) { foreach (string header in customHeaders) { failureResponse.Header.UnknownHeaders.Add(header); } } m_uasTransaction.SendFinalResponse(failureResponse); } } else { logger.LogWarning("SIPServerUserAgent Reject fired on already answered call."); } } catch (Exception excp) { logger.LogError("Exception SIPServerUserAgent Reject. " + excp.Message); } }
public SIPDialogue Answer(string contentType, string body, string toTag, SIPDialogueTransferModesEnum transferMode, string[] customHeaders) { try { m_transferMode = transferMode; if (m_uasTransaction.TransactionFinalResponse != null) { Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "UAS Answer was called on an already answered call, ignoring.", m_owner)); return(null); } else { UASStateChanged?.Invoke(this, SIPResponseStatusCodesEnum.Ok, null); if (!toTag.IsNullOrBlank()) { m_uasTransaction.LocalTag = toTag; } SIPResponse okResponse = m_uasTransaction.GetOkResponse(contentType, body); if (body != null) { okResponse.Header.ContentType = contentType; okResponse.Header.ContentLength = body.Length; okResponse.Body = body; } if (customHeaders != null && customHeaders.Length > 0) { foreach (string header in customHeaders) { okResponse.Header.UnknownHeaders.Add(header); } } if (OfferSDP == null) { // The INVITE request did not contain an SDP offer. We need to send the offer in the response and // then get the answer from the ACK. m_uasTransaction.OnAckReceived += OnAckAnswerReceived; } m_uasTransaction.SendFinalResponse(okResponse); if (OfferSDP != null) { SIPDialogue = new SIPDialogue(m_uasTransaction, m_owner, m_adminMemberId); SIPDialogue.TransferMode = transferMode; OnDialogueCreated?.Invoke(SIPDialogue); return(SIPDialogue); } else { // The dialogue cannot be created until the ACK is received. return(null); } } } catch (Exception excp) { logger.LogError("Exception SIPServerUserAgent Answer. " + excp.Message); throw; } }
public void Redirect(SIPResponseStatusCodesEnum redirectCode, SIPURI redirectURI) { UASStateChanged.Invoke(this, SIPResponseStatusCodesEnum.ExtensionRequired, "ExtensionRequired"); throw new NotImplementedException(); }