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);
}
}