SIPSorcery.SIP.SIPTransport.SendRaw C# (CSharp) Method

SendRaw() public method

Allows raw bytes to be sent from one of the SIPTransport sockets. This should not be used for SIP payloads and instead is provided to allow other types of payloads to be multi-plexed on the SIP socket. Examples are sending NAT keep alives and STUN responses where it's useful to use the same socket as the SIP packets.
public SendRaw ( SIPEndPoint localSIPEndPoint, SIPEndPoint destinationEndPoint, byte buffer ) : void
localSIPEndPoint SIPEndPoint
destinationEndPoint SIPEndPoint
buffer byte
return void
        public void SendRaw(SIPEndPoint localSIPEndPoint, SIPEndPoint destinationEndPoint, byte[] buffer)
        {
            if (destinationEndPoint != null && destinationEndPoint.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 data could not be sent.");
            }

            SIPChannel sendSIPChannel = FindSIPChannel(localSIPEndPoint);
            if (sendSIPChannel != null)
            {
                sendSIPChannel.Send(destinationEndPoint.GetIPEndPoint(), buffer);
            }
            else
            {
                logger.Warn("No SIPChannel could be found for " + localSIPEndPoint + " in SIPTransport.SendRaw, sending to " + destinationEndPoint.ToString() + ".");
                //logger.Warn(Encoding.UTF8.GetString(buffer));
            }
        }