#pragma once
|
#include <afxSock.h>
|
#include "AcceptClient.h"
|
#include <functional>
|
|
namespace BEQ {
|
|
typedef std::function<int(void* pServer, CAcceptClient* pClient)> ONACCEPT;
|
typedef std::function<int(void* pServer)> ONCLOSE;
|
|
typedef struct _ServerListener
|
{
|
ONACCEPT onAccept;
|
ONCLOSE onClose;
|
} ServerListener;
|
|
class CSocketServer :
|
public CAsyncSocket
|
{
|
public:
|
CSocketServer();
|
CSocketServer::CSocketServer(int port, BEQ::ServerListener listener);
|
~CSocketServer();
|
|
public:
|
void setListenter(BEQ::ServerListener listener);
|
void setPort(UINT port);
|
void init();
|
|
public:
|
virtual void OnAccept(int nErrorCode);
|
virtual void OnClose(int nErrorCode);
|
virtual void OnReceive(int nErrorCode);
|
|
private:
|
UINT m_port;
|
ServerListener m_listener;
|
};
|
}
|