From 7e4af7f435b17c1079e7b7326deb3738f872766f Mon Sep 17 00:00:00 2001 From: azw Date: Mon, 13 Nov 2023 07:00:11 +0000 Subject: [PATCH] 1 --- server/wsproxy/GCListener.cc | 3 +-- server/wsproxy/GCListener.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/server/wsproxy/GCListener.cc b/server/wsproxy/GCListener.cc index 59b4faa..2f530a6 100644 --- a/server/wsproxy/GCListener.cc +++ b/server/wsproxy/GCListener.cc @@ -118,7 +118,7 @@ static void GSListeneron_error(a8::TcpListener*, int type, int errorid) void GCListener::Init() { - tcp_listener_ = new a8::TcpListener(); + tcp_listener_ = std::make_shared(); tcp_listener_->RegisterSessionClass(); tcp_listener_->on_error = GSListeneron_error; @@ -147,7 +147,6 @@ void GCListener::Init() void GCListener::UnInit() { - delete tcp_listener_; tcp_listener_ = nullptr; } diff --git a/server/wsproxy/GCListener.h b/server/wsproxy/GCListener.h index dd3bfd7..ae1ca14 100644 --- a/server/wsproxy/GCListener.h +++ b/server/wsproxy/GCListener.h @@ -29,7 +29,7 @@ class GCListener : public a8::Singleton template void SendMsgEx(unsigned short socket_handle, int msgid, T& msg) { - f8::Net_SendMsg(tcp_listener_, socket_handle, 0, msgid, msg); + f8::Net_SendMsg(tcp_listener_.get(), socket_handle, 0, msgid, msg); } void SendBuf(unsigned short sockhandle, char* buf, int buflen); @@ -43,6 +43,6 @@ class GCListener : public a8::Singleton int GetSocketCount(); private: - a8::TcpListener *tcp_listener_ = nullptr; + std::shared_ptr tcp_listener_; std::map> websocket_url_hash_; };