📄 socketserver.h
字号:
// SocketServer.h: interface for the SocketLayer class.
/*/////////////////////////////////////////////////////////////////////////////
Socket层,封装了服务器基本功能
李亦
2006.06.21
/*//////////////////////////////////////////////////////////////////////////////
#if !defined(_SOCKETSERVER_H_)
#define _SOCKETSERVER_H_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifdef TGE_RPGSERVER
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#ifndef _THREADPOOL_H_
#include "server/sys/threadPool.h"
#endif
#if !defined(_SOCKETLAYER_H_)
#include "server/SocketLayer.h"
#endif
///////////////////////////////////////////////////////////////////////////////
//CS SDK
namespace CS
{
class SocketServer;
////////////////////////////////////////////////
//Socket线程池管理
#define DECLARE_SOCKETPOOL(className,Name)\
class Socket##Name##Pool : public ThreadQueue\
{\
public:\
SocketServer* m_pServer;\
Socket##Name##Pool(U32 uInit,U32 nMin, U32 nMax,U32 uLife):ThreadQueue(uInit,nMin, nMax,uLife){}\
DECLARE_THREADQ_METHOD(ProcessSockets,(CAuthSocket*));\
}
#define IMPLEMENT_SOCKETPOOL(className,Name)\
IMPLEMENT_THREADQ_METHOD(className::Socket##Name##Pool, ProcessSockets,(CAuthSocket* pSocket), (pSocket))
///////////////////////////////////////////////////////////////////////////////
//Socket Server模型管理
class SocketServer : public SocketLayer
{
typedef SocketLayer Parent;
DECLARE_SOCKETPOOL(SocketServer,Send);
DECLARE_SOCKETPOOL(SocketServer,Recv);
DECLARE_SOCKETPOOL(SocketServer,Listen);
DECLARE_SOCKETPOOL(SocketServer,Discard);
//CAuthSocket* m_pCommSock[MAX_COMMAND_SOCKETS];
//CAuthSocket* m_pConnSock[MAX_COMMAND_CONNECTIONS];
Vector<CAuthSocket*> m_arClientSockets;
Vector<CAuthSocket*> m_arListenSockets;
//int m_nCommCount;
//int m_nConnCount;
//UINT m_uIdleTimeOut;
BOOL m_bStopServer;
SocketSendPool m_sendPool;
SocketRecvPool m_recvPool;
SocketListenPool m_listenPool;
SocketDiscardPool m_discardPool;
MutexInstance m_mutexClients;
MutexInstance m_mutexListens;
public:
//BOOL Initialize(BOOL bLoadTCPModule=TRUE,BOOL bLoadUDPModule=TRUE,BOOL bLoadXOREncryption=TRUE,BOOL bLoadDESHashEncryption=TRUE,BOOL bLoadNullAuth=TRUE);
virtual void run(S32 arg);
void StopServer();
BOOL RunServer();
void ShutdownServer();
int CreateServer(CSTR szAddr, CSTR szNetMod, CSTR szEncryptionMod, CSTR szAuth);
void ProcessDiscardSocket(CAuthSocket* );
void ProcessAcceptSocket(CAuthSocket* );
void ProcessRecvSocket(CAuthSocket* );
void ProcessSendSocket(CAuthSocket* );
DECLARE_CONOBJECT(SocketServer);
public:
SocketServer();
virtual ~SocketServer();
};
};//namespace CS
#endif //#ifdef TGE_RPGSERVER
#endif // !defined(_SOCKETSERVER_H_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -