This commit is contained in:
azw 2023-09-13 13:38:04 +00:00
parent 4c8d3488f4
commit 78ccad1206
4 changed files with 5 additions and 10 deletions

View File

@ -85,7 +85,7 @@ static void GSListeneron_error(a8::TcpListener*, int type, int errorid)
void GGListener::Init()
{
tcp_listener_ = new a8::TcpListener();
tcp_listener_ = std::make_shared<a8::TcpListener>();
tcp_listener_->on_create_client_socket = CreateGameClientSocket;
tcp_listener_->on_error = GSListeneron_error;
@ -96,8 +96,6 @@ void GGListener::Init()
void GGListener::UnInit()
{
delete tcp_listener_;
tcp_listener_ = nullptr;
}
void GGListener::SendText(int sockhandle, const std::string& text)

View File

@ -22,7 +22,7 @@ class GGListener : public a8::Singleton<GGListener>
void SendMsg(int sockhandle, T& msg)
{
static int msgid = f8::Net_GetMessageId(msg);
f8::Net_SendMsg(tcp_listener_, sockhandle, 0, msgid, msg);
f8::Net_SendMsg(tcp_listener_.get(), sockhandle, 0, msgid, msg);
}
void SendText(int sockhandle, const std::string& text);
@ -31,5 +31,5 @@ class GGListener : public a8::Singleton<GGListener>
void MarkClient(int sockhandle, bool is_active);
private:
a8::TcpListener *tcp_listener_ = nullptr;
std::shared_ptr<a8::TcpListener> tcp_listener_;
};

View File

@ -51,7 +51,7 @@ const std::string App::GetPkgName()
void App::Init()
{
msg_mutex_ = new std::mutex();
msg_mutex_ = std::make_shared<std::mutex>();
HandlerMgr::Instance()->Init();
JsonDataMgr::Instance()->Init();
@ -80,9 +80,6 @@ void App::UnInit()
GGListener::Instance()->UnInit();
JsonDataMgr::Instance()->UnInit();
HandlerMgr::Instance()->UnInit();
delete msg_mutex_;
msg_mutex_ = nullptr;
}
void App::Update()

View File

@ -40,7 +40,7 @@ public:
private:
std::mutex *msg_mutex_ = nullptr;
std::shared_ptr<std::mutex> msg_mutex_;
MsgNode* top_node_ = nullptr;
MsgNode* bot_node_ = nullptr;
MsgNode* work_node_ = nullptr;