本文整理汇总了C#中SIPSorcery.SIP.SIPResponse.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# SIPResponse.Copy方法的具体用法?C# SIPResponse.Copy怎么用?C# SIPResponse.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIPSorcery.SIP.SIPResponse
的用法示例。
在下文中一共展示了SIPResponse.Copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InDialogueTransactionInfoResponseReceived
private void InDialogueTransactionInfoResponseReceived(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPTransaction sipTransaction, SIPResponse sipResponse)
{
SIPDialogue dialogue = GetDialogue(sipResponse.Header.CallId, sipResponse.Header.From.FromTag, sipResponse.Header.To.ToTag);
string owner = (dialogue != null) ? dialogue.Owner : null;
try
{
// Lookup the originating transaction.
SIPTransaction originTransaction = m_sipTransport.GetTransaction(m_inDialogueTransactions[sipTransaction.TransactionId]);
SIPResponse response = sipResponse.Copy();
response.Header.Vias = originTransaction.TransactionRequest.Header.Vias;
response.Header.To = originTransaction.TransactionRequest.Header.To;
response.Header.From = originTransaction.TransactionRequest.Header.From;
response.Header.CallId = originTransaction.TransactionRequest.Header.CallId;
response.Header.CSeq = originTransaction.TransactionRequest.Header.CSeq;
response.Header.Contact = SIPContactHeader.CreateSIPContactList(new SIPURI(originTransaction.TransactionRequest.URI.Scheme, localSIPEndPoint));
response.Header.RecordRoutes = null; // Can't change route set within a dialogue.
response.Header.UserAgent = m_userAgentString;
Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Forwarding in dialogue response from " + remoteEndPoint + " " + sipResponse.Header.CSeqMethod + " " + sipResponse.StatusCode + " " + sipResponse.ReasonPhrase + " to " + response.Header.Vias.TopViaHeader.ReceivedFromAddress + ".", owner));
// Forward the response back to the requester.
originTransaction.SendInformationalResponse(response);
}
catch (Exception excp)
{
Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.Error, "Exception processing in dialogue " + sipResponse.Header.CSeqMethod + " info response. " + excp.Message, owner));
}
}
示例2: InDialogueTransactionFinalResponseReceived
private void InDialogueTransactionFinalResponseReceived(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPTransaction sipTransaction, SIPResponse sipResponse)
{
SIPDialogue dialogue = GetDialogue(sipResponse.Header.CallId, sipResponse.Header.From.FromTag, sipResponse.Header.To.ToTag);
string owner = (dialogue != null) ? dialogue.Owner : null;
try
{
logger.Debug("Final response of " + sipResponse.StatusCode + " on " + sipResponse.Header.CSeqMethod + " in-dialogue transaction.");
// Lookup the originating transaction.
SIPTransaction originTransaction = m_sipTransport.GetTransaction(m_inDialogueTransactions[sipTransaction.TransactionId]);
IPAddress remoteUAIPAddress = (sipResponse.Header.ProxyReceivedFrom.IsNullOrBlank()) ? remoteEndPoint.Address : SIPEndPoint.ParseSIPEndPoint(sipResponse.Header.ProxyReceivedFrom).Address;
SIPEndPoint forwardSIPEndPoint = m_sipTransport.GetDefaultSIPEndPoint(sipResponse.Header.Vias.TopViaHeader.Transport);
SIPResponse response = sipResponse.Copy();
response.Header.Vias = originTransaction.TransactionRequest.Header.Vias;
response.Header.To = originTransaction.TransactionRequest.Header.To;
response.Header.From = originTransaction.TransactionRequest.Header.From;
response.Header.CallId = originTransaction.TransactionRequest.Header.CallId;
response.Header.CSeq = originTransaction.TransactionRequest.Header.CSeq;
response.Header.Contact = new List<SIPContactHeader>() { new SIPContactHeader(null, new SIPURI(originTransaction.TransactionRequest.URI.Scheme, forwardSIPEndPoint)) };
response.Header.RecordRoutes = null; // Can't change route set within a dialogue.
response.Header.UserAgent = m_userAgentString;
if (sipResponse.Body != null && sipResponse.Header.CSeqMethod == SIPMethodsEnum.INVITE)
{
bool wasMangled = false;
response.Body = SIPPacketMangler.MangleSDP(sipResponse.Body, remoteUAIPAddress.ToString(), out wasMangled);
response.Header.ContentLength = response.Body.Length;
}
Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Forwarding in dialogue response from " + remoteEndPoint + " " + sipResponse.Header.CSeqMethod + " final response " + sipResponse.StatusCode + " " + sipResponse.ReasonPhrase + " to " + response.Header.Vias.TopViaHeader.ReceivedFromAddress + ".", owner));
// Forward the response back to the requester.
originTransaction.SendFinalResponse(response);
}
catch (Exception excp)
{
Log_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.Error, "Exception processing in dialogue " + sipResponse.Header.CSeqMethod + " final response. " + excp.Message, owner));
}
}