SIPSorcery.SIP.SIPTLSChannel.ReceiveCallback C# (CSharp) Method

ReceiveCallback() public method

public ReceiveCallback ( IAsyncResult ar ) : void
ar IAsyncResult
return void
        public void ReceiveCallback(IAsyncResult ar)
        {
            SIPConnection sipTLSConnection = (SIPConnection)ar.AsyncState;

            if (sipTLSConnection != null && sipTLSConnection.SIPStream != null && sipTLSConnection.SIPStream.CanRead)
            {
                try
                {
                    int bytesRead = sipTLSConnection.SIPStream.EndRead(ar);
                    if (sipTLSConnection.SocketReadCompleted(bytesRead))
                    {
                        sipTLSConnection.SIPStream.BeginRead(sipTLSConnection.SocketBuffer, sipTLSConnection.SocketBufferEndPosition, MaxSIPTCPMessageSize - sipTLSConnection.SocketBufferEndPosition, new AsyncCallback(ReceiveCallback), sipTLSConnection);
                    }
                }
                catch (SocketException sockExcp)  // Occurs if the remote end gets disconnected.
                {
                    logger.Warn("SocketException SIPTLSChannel ReceiveCallback. " + sockExcp);
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception SIPTLSChannel ReceiveCallback. " + excp);
                    SIPTLSSocketDisconnected(sipTLSConnection.RemoteEndPoint);
                }
            }
        }