?? qtcpmsgserver.h
字號(hào):
#ifndef QTcpMsgServerH
#define QTcpMsgServerH
#include "Interface_QTcpMsgServer.h"
#include "../QTemplateBase/QTemplateBase.h"
#include "../QAsynTcpServer/Interface_QAsynTcpServer.h"
#include "../QAsynTcpServer/Interface_QTcpListenDevice.h"
#include <assert.h>
#include <vector>
#include <stlport/hash_map>
namespace N_QTcpMsgServer {
//---------------------------------------------------------------------------
struct ITEM
{
int Sock;
std::string Buf;
};
struct MSGITEM
{
int SessionID;
std::string Msg;
};
//---------------------------------------------------------------------------
class QTcpMsgServer : public IQTcpMsgServer
{
public:
__stdcall QTcpMsgServer();
virtual __stdcall ~QTcpMsgServer();
virtual void __stdcall Release() { assert(this); delete this; }
virtual bool __stdcall Start(unsigned int Port, unsigned int MaxSession
, const std::string& EndSign, unsigned int MaxPackage);
virtual void __stdcall Stop(void);
virtual bool __stdcall IsPowerOn(void)const;
virtual bool __stdcall Send(int SessionID, const std::string& Msg);
virtual bool __stdcall GetQueuedMsg(int* pSessionID, std::string* pMsg);//當(dāng)返回pMsg為空表示該Session斷開,在GC機(jī)制下可以不理會(huì)
virtual std::string __stdcall GetAddress(int SessionID)const;
virtual void __stdcall ShutDown(int SessionID);
virtual void __stdcall Process(void);
virtual void __stdcall ProcessGC(void);
virtual void __stdcall SetTimeOut(unsigned int TimeOut);
virtual bool __stdcall IsExist(int SessionID)const;
virtual unsigned int __stdcall GetCount(void)const;
virtual void __stdcall SetReadLastData(bool IsReadLast);
virtual int __stdcall PushSocket(int Sock);
private:
bool __stdcall Append(int Sock);
void __stdcall Remove(int SessionID);
void __stdcall ProcessAccept(void);
void __stdcall ProcessDelete(void);
void __stdcall ProcessRecv(void);
typedef std::hash_map<unsigned int, ITEM> ID_MAP;
IQAsynTcpServer* m_Server;
IQTcpListenDevice* m_Listener;
QBasicMsg<MSGITEM> m_Msg;
ID_MAP m_Map;
unsigned int m_NewIter;
unsigned int m_MaxSession;
std::string m_EndSign;
unsigned int m_MaxPackage;
bool m_IsReadLastData;
};
//---------------------------------------------------------------------------
}//namespace
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -