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

📄 sipagent.h

📁 一个SIP协议栈
💻 H
字号:
#ifndef __SIPAGENT_H__#define __SIPAGENT_H__#include "SIPReceiver.h"#include "SIPTransmitter.h"#include "SIPRetransmitManager.h"namespace msip{    typedef int TransmitID;    ///The middle level of SIP stack - SIP Agent.    class Agent    {    private:        ///Message Receiver        MsgReceiver ag_Receiver;        struct TransmitItem        {            Transmitter       m_trans;            RetransmitManager m_retrans;            std::mstring      m_buffer;        };        typedef std::vector<TransmitItem*> TransArray;        ///Array of transmitters        TransArray  ag_Transmitters;    public:        ///Constructor        Agent(int udp_port=5060, int tcp_port=5060);        ///Destructor        ~Agent();        /**@name Listening and Process functions */        //@{        ///Adds descriptors to fd_set         void addToFdSet(fd_set* fds) const { ag_Receiver.addToFdSet(fds); }        /// Poll incoming channels. Returns true if there is something to do.        bool poll(fd_set* fds);        /// True if the Incoming queue is empty        bool notEmpty() const { return ag_Receiver.notEmpty(); }         /// Receive a message        MsgReceiver::ReceiveResult receive(Message* msg, mh323::IPAddress* addr_from)        { return ag_Receiver.receive(msg, addr_from); }        //@}        /**@name Transmitting functions */        //@{        /** Create a connection via TCP or UDP. Using UDP may mean that there             is nothing to do. It may be used for the unify only. When the TCP is            used the transmiter creates a real connection. After we creates            the connection we will be abble to send messages via this connection.            The pointer to the Transmitter is used as a descriptor (or identifier            of this connection). There several forms of call are possible:            transmitter = connect(viaTCP, "remote_host", 5060);            transmitter = connect(viaTCP, "195.67.176.77", 6061);            transmitter = connect(viaTCP, "remote_host:5060");             When the port is indicated as a parameter it will be used            (The parameter has a higher priority)*/        TransmitID connect(SendVia via, const std::string & addr, int port=0);        /** Set retransmition scheme */        void setTimeoutValues(TransmitID connection, long t1=500, long t2=4000, double exp_val=2.0);        /** Send a message via the opened connection */        bool send(TransmitID connection, /*const*/ Message& msg, bool retry_flag=false);        /** Send a message as a local transaction (connect, send, close) */        bool send(SendVia via, /*const*/ Message& msg, const std::string & addr, int port=0) const;        /** Stop retransmittions */        void stopRetransmit(TransmitID connection);        /** Close existed connection */        bool close(TransmitID connection);        /** Get minimal time interval in milliseconds that one should            pass to the function "select". */        long getMinimalTimeLeft(long min_time_left) const;        //@}    };}#endif

⌨️ 快捷键说明

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