本文整理汇总了C#中SIPSorcery.SIP.SIPResponse.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SIPResponse.ToString方法的具体用法?C# SIPResponse.ToString怎么用?C# SIPResponse.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIPSorcery.SIP.SIPResponse
的用法示例。
在下文中一共展示了SIPResponse.ToString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendResponse
private void SendResponse(SIPChannel sipChannel, SIPEndPoint dstEndPoint, SIPResponse sipResponse)
{
try
{
if (dstEndPoint != null && dstEndPoint.Address.Equals(BlackholeAddress))
{
// Ignore packet, it's destined for the blackhole.
return;
}
if (m_sipChannels.Count == 0)
{
throw new ApplicationException("No channels are configured in the SIP transport layer. The response could not be sent.");
}
sipResponse.Header.ContentLength = (sipResponse.Body.NotNullOrBlank()) ? Encoding.UTF8.GetByteCount(sipResponse.Body) : 0;
sipChannel.Send(dstEndPoint.GetIPEndPoint(), Encoding.UTF8.GetBytes(sipResponse.ToString()));
if (SIPRequestOutTraceEvent != null)
{
FireSIPResponseOutTraceEvent(sipChannel.SIPChannelEndPoint, dstEndPoint, sipResponse);
}
}
catch (ApplicationException appExcp)
{
logger.Warn("ApplicationException SIPTransport SendResponse. " + appExcp.Message);
}
}
示例2: LogSIPResponseOut
private void LogSIPResponseOut(SIPEndPoint localSIPEndPoint, SIPEndPoint endPoint, SIPResponse sipResponse)
{
string message = "App Svr Sent: " + localSIPEndPoint.ToString() + "->" + endPoint.ToString() + "\r\n" + sipResponse.ToString();
//logger.Debug("as: response out " + sipResponse.Header.CSeqMethod + " " + localSIPEndPoint.ToString() + "->" + endPoint.ToString() + ", callid=" + sipResponse.Header.CallId + ".");
string fromUser = (sipResponse.Header.From != null && sipResponse.Header.From.FromURI != null) ? sipResponse.Header.From.FromURI.User : "Error on From header";
FireSIPMonitorEvent(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.FullSIPTrace, message, fromUser, localSIPEndPoint, endPoint));
}
示例3: GotResponse
/// <summary>
/// From RFC3261: Stateless Proxy Response Processing:
///
/// When a response arrives at a stateless proxy, the proxy MUST inspect the sent-by value in the first
/// (topmost) Via header field value. If that address matches the proxy, (it equals a value this proxy has
/// inserted into previous requests) the proxy MUST remove that header field value from the response and
/// forward the result to the location indicated in the next Via header field value. The proxy MUST NOT add
/// to, modify, or remove the message body. Unless specified otherwise, the proxy MUST NOT remove
/// any other header field values. If the address does not match the proxy, the message MUST be silently discarded.
/// </summary>
private void GotResponse(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPResponse sipResponse)
{
try
{
// Used in the proxy monitor messages only, plays no part in response processing.
string fromUser = (sipResponse.Header.From != null) ? sipResponse.Header.From.FromURI.User : null;
string toUser = (sipResponse.Header.To != null) ? sipResponse.Header.To.ToURI.User : null;
string summaryStr = "resp " + sipResponse.Header.CSeqMethod + " from=" + fromUser + ", to=" + toUser + ", " + remoteEndPoint.ToString();
SIPViaHeader topVia = sipResponse.Header.Vias.PopTopViaHeader();
SIPEndPoint outSocket = localSIPEndPoint;
// If the second Via header on the response was also set by this proxy it means the request was originally received and forwarded
// on different sockets. To get the response to travel the same path in reverse it must be forwarded from the proxy socket indicated
// by the second top Via.
if (sipResponse.Header.Vias.Length > 1)
{
SIPViaHeader nextTopVia = sipResponse.Header.Vias.TopViaHeader;
SIPEndPoint nextTopViaSIPEndPoint = SIPEndPoint.ParseSIPEndPoint(nextTopVia.Transport + ":" + nextTopVia.ReceivedFromAddress);
//if (!(PublicIPAddress != null && nextTopVia.ReceivedFromIPAddress != null && nextTopVia.ReceivedFromIPAddress != PublicIPAddress.ToString())
// &&
// (m_sipTransport.IsLocalSIPEndPoint(nextTopViaSIPEndPoint) || (PublicIPAddress != null && nextTopVia.ReceivedFromIPAddress == PublicIPAddress.ToString())))
if(m_sipTransport.IsLocalSIPEndPoint(nextTopViaSIPEndPoint))
{
sipResponse.Header.Vias.PopTopViaHeader();
outSocket = nextTopViaSIPEndPoint;
}
}
bool isFromAppServer = (m_sipCallDispatcherFile != null) ? m_sipCallDispatcherFile.IsAppServerEndPoint(remoteEndPoint) : false;
lock (this)
{
m_compiledScript.DefaultScope.RemoveVariable("sys");
m_compiledScript.DefaultScope.RemoveVariable("isreq");
m_compiledScript.DefaultScope.RemoveVariable("localEndPoint");
m_compiledScript.DefaultScope.RemoveVariable("outSocket");
m_compiledScript.DefaultScope.RemoveVariable("resp");
m_compiledScript.DefaultScope.RemoveVariable("remoteEndPoint");
m_compiledScript.DefaultScope.RemoveVariable("summary");
m_compiledScript.DefaultScope.RemoveVariable("sipMethod");
m_compiledScript.DefaultScope.RemoveVariable("topVia");
m_compiledScript.DefaultScope.RemoveVariable("IsFromAppServer");
m_compiledScript.DefaultScope.SetVariable("sys", m_proxyScriptFacade);
m_compiledScript.DefaultScope.SetVariable("isreq", false);
m_compiledScript.DefaultScope.SetVariable("localEndPoint", localSIPEndPoint);
m_compiledScript.DefaultScope.SetVariable("outSocket", outSocket);
m_compiledScript.DefaultScope.SetVariable("resp", sipResponse);
m_compiledScript.DefaultScope.SetVariable("remoteEndPoint", remoteEndPoint);
m_compiledScript.DefaultScope.SetVariable("summary", summaryStr);
m_compiledScript.DefaultScope.SetVariable("sipMethod", sipResponse.Header.CSeqMethod.ToString());
m_compiledScript.DefaultScope.SetVariable("topVia", topVia);
m_compiledScript.DefaultScope.SetVariable("IsFromAppServer", isFromAppServer);
m_compiledScript.Execute();
}
//if (responseStopwatch.ElapsedMilliseconds > 20)
//{
// logger.Debug("GotResponse processing time=" + responseStopwatch.ElapsedMilliseconds + "ms, script time=" + scriptStopwatch.ElapsedMilliseconds + "ms.");
//}
}
catch (Exception excp)
{
string respExcpError = "Exception SIPProxyCore GotResponse. " + excp.Message;
logger.Error(respExcpError + "\n" + sipResponse.ToString());
SIPMonitorEvent respExcpEvent = new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.SIPProxy, SIPMonitorEventTypesEnum.Error, respExcpError, localSIPEndPoint, remoteEndPoint, null);
SendMonitorEvent(respExcpEvent);
throw excp;
}
}
示例4: sipTransport1_SIPResponseInTraceEvent
void sipTransport1_SIPResponseInTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint fromEndPoint, SIPResponse sipResponse)
{
Console.WriteLine("Response Received: " + localEndPoint.ToString() + "<-" + fromEndPoint.ToString() + "\r\n" + sipResponse.ToString());
}
示例5: sipTransport2_SIPResponseOutTraceEvent
void sipTransport2_SIPResponseOutTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint toEndPoint, SIPResponse sipResponse)
{
Console.WriteLine("Response Sent: " + localEndPoint.ToString() + "<-" + toEndPoint.ToString() + "\r\n" + sipResponse.ToString());
}
示例6: SendTransparent
/// <summary>
/// This method is the equivalent to the same named method for sending SIP requests. The two methods are used to allow the Proxy to
/// deliver requests to external SIP agents with only a SINGLE Via header due to a small number of providers rejecting requests with
/// more than one Via header.
/// </summary>
/// <param name="receivedFromEP">The socket the response was received from.</param>
/// <param name="receivedOnEP">The proxy socket the response was received on.</param>
/// <param name="sipResponse">The response being forwarded.</param>
/// <param name="localSIPEndPoint">The proxy socket to forward the request from.</param>
/// <param name="dstSIPEndPoint">The internal destination socket to forward the response to.</param>
/// <param name="proxyBranch">The branch parameter from the top Via header that needs to be reused when forwarding the response.</param>
public void SendTransparent(SIPEndPoint receivedFromEP, SIPEndPoint receivedOnEP, SIPResponse sipResponse, SIPEndPoint localSIPEndPoint, SIPEndPoint dstSIPEndPoint, string proxyBranch)
{
try
{
sipResponse.Header.ProxyReceivedFrom = receivedFromEP.ToString();
sipResponse.Header.ProxyReceivedOn = receivedOnEP.ToString();
sipResponse.Header.Vias.PushViaHeader(new SIPViaHeader(dstSIPEndPoint, proxyBranch));
sipResponse.LocalSIPEndPoint = localSIPEndPoint;
m_sipTransport.SendResponse(sipResponse);
}
catch (Exception excp)
{
logger.Error("Exception SIPResponse SendInternal. " + excp.Message);
logger.Error(sipResponse.ToString());
throw;
}
}
示例7: GotResponse
public void GotResponse(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPResponse sipResponse)
{
FireProxyLogEvent(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.Error, "App Server received a SIP response from " + remoteEndPoint + " that did not match an existing transaction.\n" + sipResponse.ToString(), null));
}
示例8: SIPResponseOutTraceEvent
private static void SIPResponseOutTraceEvent(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPResponse sipResponse)
{
logger.DebugFormat("RESPONSE OUT {0}->{1}", localSIPEndPoint.ToString(), remoteEndPoint.ToString());
logger.Debug(sipResponse.ToString());
}
示例9: SendInternal
public void SendInternal(SIPEndPoint receivedFromEP, SIPEndPoint receivedOnEP, SIPResponse sipResponse, SIPEndPoint localSIPEndPoint)
{
try
{
sipResponse.Header.ProxyReceivedFrom = receivedFromEP.ToString();
sipResponse.Header.ProxyReceivedOn = receivedOnEP.ToString();
sipResponse.LocalSIPEndPoint = localSIPEndPoint;
m_sipTransport.SendResponse(sipResponse);
}
catch (Exception excp)
{
logger.Error("Exception SIPResponse SendInternal. " + excp.Message);
logger.Error(sipResponse.ToString());
throw;
}
}
示例10: transport_SIPResponseInTraceEvent
void transport_SIPResponseInTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint fromEndPoint, SIPResponse sipResponse)
{
Console.WriteLine("Response In: " + localEndPoint + "<-" + fromEndPoint.ToString() + "\n" + sipResponse.ToString());
}
示例11: transport_SIPResponseOutTraceEvent
void transport_SIPResponseOutTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint toEndPoint, SIPResponse sipResponse)
{
Console.WriteLine("Response Out: " + localEndPoint + "->" + toEndPoint.ToString() + "\n" + sipResponse.ToString());
}
示例12: SendInformationalResponse
public virtual void SendInformationalResponse(SIPResponse sipResponse)
{
FireTransactionTraceMessage("Send Info Response " + LocalSIPEndPoint.ToString() + "->" + this.RemoteEndPoint + m_crLF + sipResponse.ToString());
if (sipResponse.StatusCode == 100)
{
UpdateTransactionState(SIPTransactionStatesEnum.Trying);
}
else if (sipResponse.StatusCode > 100 && sipResponse.StatusCode <= 199)
{
UpdateTransactionState(SIPTransactionStatesEnum.Proceeding);
}
m_sipTransport.SendResponse(sipResponse);
}
示例13: SendFinalResponse
public virtual void SendFinalResponse(SIPResponse finalResponse)
{
m_transactionFinalResponse = finalResponse;
UpdateTransactionState(SIPTransactionStatesEnum.Completed);
string viaAddress = finalResponse.Header.Vias.TopViaHeader.ReceivedFromAddress;
if (TransactionType == SIPTransactionTypesEnum.Invite)
{
FireTransactionTraceMessage("Send Final Response Reliable " + LocalSIPEndPoint.ToString() + "->" + viaAddress + m_crLF + finalResponse.ToString());
m_sipTransport.SendSIPReliable(this);
}
else
{
FireTransactionTraceMessage("Send Final Response " + LocalSIPEndPoint.ToString() + "->" + viaAddress + m_crLF + finalResponse.ToString());
m_sipTransport.SendResponse(finalResponse);
}
}
示例14: GotResponse
public void GotResponse(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPResponse sipResponse)
{
if (TransactionState == SIPTransactionStatesEnum.Completed || TransactionState == SIPTransactionStatesEnum.Confirmed)
{
FireTransactionTraceMessage("Received Duplicate Response " + localSIPEndPoint.ToString() + "<-" + remoteEndPoint + m_crLF + sipResponse.ToString());
if (sipResponse.Header.CSeqMethod == SIPMethodsEnum.INVITE)
{
if (sipResponse.StatusCode >= 100 && sipResponse.StatusCode <= 199)
{
// Ignore info response on completed transaction.
}
else
{
ResendAckRequest();
}
}
if (TransactionDuplicateResponse != null)
{
TransactionDuplicateResponse(localSIPEndPoint, remoteEndPoint, this, sipResponse);
}
}
else
{
FireTransactionTraceMessage("Received Response " + localSIPEndPoint.ToString() + "<-" + remoteEndPoint + m_crLF + sipResponse.ToString());
if (sipResponse.StatusCode >= 100 && sipResponse.StatusCode <= 199)
{
UpdateTransactionState(SIPTransactionStatesEnum.Proceeding);
TransactionInformationResponseReceived(localSIPEndPoint, remoteEndPoint, this, sipResponse);
}
else
{
m_transactionFinalResponse = sipResponse;
UpdateTransactionState(SIPTransactionStatesEnum.Completed);
TransactionFinalResponseReceived(localSIPEndPoint, remoteEndPoint, this, sipResponse);
}
}
}