⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sipmessage.h

📁 一个SIP协议栈
💻 H
字号:
#ifndef __SIPMESSAGE_H__
#define __SIPMESSAGE_H__


#include "SIPParser.h"


namespace msip
{


    ///Making a SIP-url for convinience
    class SipUrl : public MpUrl
    {
    public:
        SipUrl(const std::mstring& user, const std::mstring& passwd, 
               const std::mstring& host, int port=0,
               const std::mstring& transport="", int ttl=0,
               const std::mstring& maddr="", 
               const std::mstring& tag="")
        : MpUrl(sipProtoNameL)
        {
            (*this)[mpiUserInfo].val(mpnUser) = user;
            (*this)[mpiUserInfo].val(mpnPasswd) = user;
            (*this)[mpiHostPort].val(mpnHost) = host;
            if(port) (*this)[mpiHostPort].val(mpnPort).assigni(port, "%d");
            if(!transport.empty()) (*this)[mpiUrlParm].val(mpnTransport) = transport;
            if(ttl) (*this)[mpiUrlParm].val(mpnTtl).assigni(ttl, "%d");
            if(!maddr.empty()) (*this)[mpiUrlParm].val(mpnMaddr) = maddr;
            if(!tag.empty()) (*this)[mpiUrlParm].val(mpnTag) = tag;
        }
    private:
        SipUrl(const SipUrl &);
        SipUrl & operator = (const SipUrl &);
    };



    //==================================================================================
    ///
    class Message : public MsgParser
    {
    private:
        std::mstring m_Proto;
        std::mstring m_Version;

    public:
        MpMsgType getMethod() const { return startLine().getMethod(); }

        void setBadRequest(const std::mstring & reason);

        /**Set current protocol string (SIP, SIP+). 
        This string will be used in making the start line and the via headers. */
        void setProto(const std::mstring & proto);

        /**Set protocol version. 
        This string will be used in making the start line and the via headers. */
        void setVersion(const std::mstring & proto);

        ///Add start line to a request-type message
        void addStartLineRequest(MpMsgType method, const std::mstring& url);

        ///Add start line to a response-type message
        void addStartLineResponse(MpResponseCode code, const std::mstring& url, 
                                  const std::mstring& reason_phrase);

        ///Add From header
        void addFrom(const std::mstring& display, const MpUrl &url, const std::mstring& tag);

        ///Add To header
        void addTo(const std::mstring& display, const MpUrl &url, const std::mstring& tag);
    };


}


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -