SIPSorcery.Net.RTSPRequest.ToString C# (CSharp) Méthode

ToString() public méthode

public ToString ( ) : string
Résultat string
        public new string ToString()
        {
            try
            {
                string methodStr = (Method != RTSPMethodsEnum.UNKNOWN) ? Method.ToString() : UnknownMethod;

                string message = methodStr + " " + URL.ToString() + " " + RTSPVersion + m_CRLF;
                message += (Header != null) ? Header.ToString() : null;

                if(Body != null)
                {
                    message += m_CRLF + Body;
                }
                else
                {
                    message += m_CRLF;
                }

                return message;
            }
            catch(Exception excp)
            {
                logger.Error("Exception RTSPRequest ToString. " + excp.Message);
                throw excp;
            }
        }

Usage Example

        /// <summary>
        /// Sends the RTSP teardown request for an existing RTSP session.
        /// </summary>
        private void Teardown()
        {
            try
            {
                if (_rtspStream != null && _rtspConnection.Connected)
                {
                    logger.LogDebug("RTSP client sending teardown request for " + _url + ".");

                    RTSPRequest teardownRequest = new RTSPRequest(RTSPMethodsEnum.TEARDOWN, _url);
                    RTSPHeader  teardownHeader  = new RTSPHeader(_cseq++, _rtspSession.SessionID);
                    teardownRequest.Header = teardownHeader;

                    System.Diagnostics.Debug.WriteLine(teardownRequest.ToString());

                    var buffer = Encoding.UTF8.GetBytes(teardownRequest.ToString());
                    _rtspStream.Write(buffer, 0, buffer.Length);
                }
                else
                {
                    logger.LogDebug("RTSP client did not send teardown request for " + _url + ", the socket was closed.");
                }
            }
            catch (Exception excp)
            {
                logger.LogError("Exception RTSPClient.Teardown. " + excp);
            }
        }
All Usage Examples Of SIPSorcery.Net.RTSPRequest::ToString