private void HangupDialogue(SIPDialogue dialogue, string hangupCause, bool sendBye) { if (dialogue.CDRId != Guid.Empty) { CDR cdr = m_cdrDataLayer.Get(dialogue.CDRId); if (cdr != null) { //cdr.BridgeID = dialogue.BridgeId; //cdr.Hungup(hangupCause); m_cdrDataLayer.Hangup(cdr.ID, hangupCause); } else { logger.LogWarning("CDR could not be found for remote dialogue in SIPCallManager CallHungup."); } } else { logger.LogWarning("There was no CDR attached to orphaned dialogue in SIPCallManager CallHungup."); } if (sendBye) { dialogue.Hangup(m_sipTransport, m_outboundProxy); OnCallHungup?.Invoke(dialogue); } m_sipCallDataLayer.Delete(dialogue.Id); }
/// <summary> /// The current call has ended. Reset the state of the user agent. /// </summary> private void CallEnded() { m_uac = null; m_uas = null; if (MediaSession != null && !MediaSession.IsClosed) { MediaSession.Close("normal"); MediaSession = null; } OnCallHungup?.Invoke(); }
/// <summary> /// The current call has ended. Reset the state of the user agent. /// </summary> private void CallEnded() { m_uac = null; m_uas = null; if (MediaSession != null) { MediaSession.SessionMediaChanged -= MediaSessionOnSessionMediaChanged; MediaSession.Close(); MediaSession = null; } OnCallHungup?.Invoke(); }
private void HangupDialogue(SIPDialogue dialogue, string hangupCause, bool sendBye) { if (dialogue.CDRId != Guid.Empty) { CDR cdr = m_cdrDataLayer.Get(dialogue.CDRId); if (cdr != null) { //cdr.BridgeID = dialogue.BridgeId; //cdr.Hungup(hangupCause); m_cdrDataLayer.Hangup(cdr.ID, hangupCause); } else { logger.LogWarning("CDR could not be found for remote dialogue in SIPCallManager CallHungup."); } } else { logger.LogWarning("There was no CDR attached to orphaned dialogue in SIPCallManager CallHungup."); } if (sendBye) { // In order to help cope with IPv4 NAT's apply some logic to determine if the Contact header URI looks likely // to fail which in turn would result in any in-dialgoue requests not being delivered. //var target = dialogue.RemoteTarget; //var mangledTarget = SIPURI.Mangle(target, dialogue.RemoteSIPEndPoint?.GetIPEndPoint()); //if (mangledTarget != null) //{ // logger.LogDebug($"SIPCallManager adjusting BYE target from {target} to {mangledTarget}."); // target = mangledTarget; //} //dialogue.Hangup(m_sipTransport, m_outboundProxy, target); dialogue.Hangup(m_sipTransport, dialogue.RemoteSIPEndPoint); OnCallHungup?.Invoke(dialogue); } m_sipCallDataLayer.Delete(dialogue.Id); }
/// <summary> /// This method takes the necessary actions to terminate a bridged call. /// </summary> /// <param name="sipDialogue">The dialogue that the BYE request was received on.</param> /// <param name="hangupCause">If present an informational field to indicate the hangup cause.</param> /// <param name="sendBYEForOriginDialogue">If true means a BYE should be sent for the origin dialogue as well. This is used when a 3rd party /// call control agent is attempting to hangup a call.</param> public void CallHungup(SIPDialogue sipDialogue, string hangupCause, bool sendBYEForOriginDialogue) { if (sipDialogue != null) { //logger.Debug("BYE received on dialogue " + sipDialogue.DialogueName + "."); HangupDialogue(sipDialogue, hangupCause, sendBYEForOriginDialogue); if (sipDialogue.BridgeId != Guid.Empty) { SIPDialogue orphanedDialogue = GetOppositeDialogue(sipDialogue); if (orphanedDialogue != null) { HangupDialogue(orphanedDialogue, m_remoteHangupCause, true); OnCallHungup?.Invoke(orphanedDialogue); } } else { logger.LogWarning("No bridge could be found for hungup call."); } OnCallHungup?.Invoke(sipDialogue); } }