📄 sipreceiver.h
字号:
#ifndef __SIPRECEIVER_H__#define __SIPRECEIVER_H__/********************************************************************* $Id: SIPReceiver.h,v 1.3 1999/08/31 02:22:05 cullen Exp $ ********************************************************************* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. In addition to the terms and conditions set forth in the GNU Lesser General Public License, as a condition of using this library you are required to grant to all users of this library or any implementation utilizing or derived from this library a reciprocal, no cost, worldwide, perpetual, non-exclusive, non-transferable, unrestricted license to your claims of all patents and patent applications throughout the world that are infringed by the library or any implementation utilizing or derived from this library. In the event you redistribute this library or any implementation utilizing or derived from this library, you must prominently display the foregoing terms and conditions with the library or the implementation utilizing or derived from this library. In the event of a conflict of terms between the foregoing license grant and the terms set forth in the GNU Lesser General Public License, the foregoing terms and conditions shall be deemed to govern. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not; write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Copyright 1999 Vovida Networks, Inc. All Rights Reserved. ********************************************************************* $Log: SIPReceiver.h,v $ Revision 1.3 1999/08/31 02:22:05 cullen updated header **********************************************************************/#include <vector>#include "mstring.h"#include "SIPTimer.h"#include "TCPSocket.h"#include "IPAddress.h"#include "UDPSocket.h"#include "SIPMessage.h"namespace msip{ unsigned const recvBufSize = 4096; //================================================================================== /// class MsgReceiver { ///IP Address and Socket Descriptor struct RecvBufferItem { mh323::IPAddress m_addr; int m_id; std::mstring m_str; Timer m_tm; bool equal(const mh323::IPAddress& addr, int id) const; }; struct SocketItem { mh323::TCPSocket* m_sock; int m_id; }; typedef std::vector<RecvBufferItem> RecvBuffer; typedef std::vector<SocketItem> SockArray; ///UDP Socket mh323::UDPSocket mr_UdpSocket; ///TCP Listener Socket mh323::TCPSocket mr_TcpListener; ///Connected TCP Sockets SockArray mr_TcpSockets; ///Receive Buffer RecvBuffer mr_RecvBuffer; ///Queue is Empty bool mr_EmptyFlag; ///Current ID int mr_CurrentID; ///Max Time To Live for Incomplete Messages static long mr_MaxTTL; public: ///Result of Last process Call enum ReceiveResult { resNoMessages, resReceived, resBadRequest }; ///Consructor MsgReceiver(int udp_port=5060, int tcp_port=5060); ///Consructor ~MsgReceiver(); ///The corporate standard by Vovida - adding to a file descriptor set void addToFdSet(fd_set* fds) const; ///If the input queue empty bool notEmpty() const { return !mr_EmptyFlag; } ///Poll incoming messages bool poll(fd_set * fds); ///Receive one message from the incoming queue ReceiveResult receive(Message* msg, mh323::IPAddress* addr_from); ///Auxilliary - Set Maximum Time To Live for Incomplete Messages static void setMaxTTL(long milli_sec) { mr_MaxTTL = milli_sec; } private: ///Add the next part of the message to the queue void addMsg(const mh323::IPAddress& addr, int id, const std::mstring& buf); ///Check, whether there are more ready messages bool checkReady(); };}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -