private Task <SocketError> OnAckAnswerReceived(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPTransaction sipTransaction, SIPRequest sipRequest) { SIPDialogue = new SIPDialogue(m_uasTransaction); SIPDialogue.TransferMode = m_transferMode; OnDialogueCreated?.Invoke(SIPDialogue); return(Task.FromResult(SocketError.Success)); }
public SIPDialogue Answer(string contentType, string body, string toTag, SIPDialogueTransferModesEnum transferMode, string[] customHeaders) { try { m_transferMode = transferMode; if (m_uasTransaction.TransactionFinalResponse != null) { logger.LogDebug("UAS Answer was called on an already answered call, ignoring."); 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); 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; } }