1
This commit is contained in:
parent
a8cb80fd26
commit
56f576e60d
@ -190,8 +190,8 @@ namespace a8
|
||||
clients_mutex.unlock();
|
||||
|
||||
if (!session) {
|
||||
if (master->on_create_client_socket) {
|
||||
master->on_create_client_socket(&session);
|
||||
if (master->on_create_client_socket_) {
|
||||
master->on_create_client_socket_(&session);
|
||||
if (session) {
|
||||
if (!session->AllocRecvBuf()) {
|
||||
delete session;
|
||||
|
@ -18,7 +18,6 @@ namespace a8
|
||||
class TcpListener
|
||||
{
|
||||
public:
|
||||
std::function<void (a8::TcpSession**)> on_create_client_socket;
|
||||
std::function<void (const char*, int, bool&)> on_client_connect;
|
||||
std::function<void (a8::TcpListener*, a8::TCPLISTENER_E, int)> on_error;
|
||||
std::string bind_address;
|
||||
@ -35,6 +34,15 @@ namespace a8
|
||||
void Open();
|
||||
void Close();
|
||||
bool IsActive();
|
||||
template <typename T>
|
||||
void RegisterSessionClass()
|
||||
{
|
||||
on_create_client_socket_ =
|
||||
[] (a8::TcpSession** p)
|
||||
{
|
||||
*p = new T;
|
||||
};
|
||||
}
|
||||
bool SendClientMsg(unsigned short sockhandle, const char *buff, int buffLen);
|
||||
void BroadcastMsg(const char* buff, int bufflen);
|
||||
|
||||
@ -42,6 +50,7 @@ namespace a8
|
||||
void MarkClient(unsigned short sockhandle, bool is_active);
|
||||
int GetClientSocketCount();
|
||||
int GetPoolSocketCount();
|
||||
|
||||
private:
|
||||
|
||||
void LockClients();
|
||||
@ -50,6 +59,7 @@ namespace a8
|
||||
|
||||
a8::TcpSession* GetClientSession(unsigned short handle);
|
||||
private:
|
||||
std::function<void (a8::TcpSession**)> on_create_client_socket_;
|
||||
a8::TcpListenerImpl* impl_ = nullptr;
|
||||
|
||||
friend class TcpSession;
|
||||
|
Loading…
x
Reference in New Issue
Block a user