diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index e5e19d5..993cd6b 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -5,6 +5,7 @@ #include #include "framework/cpp/netmsghandler.h" +#include "framework/cpp/msgqueue.h" #include "app.h" #include "GGListener.h" @@ -79,6 +80,10 @@ static void CreateGameClientSocket(a8::TcpSession **p) static void GSListeneron_error(a8::TcpListener*, int type, int errorid) { a8::UdpLog::Instance()->Debug("GGListeneron_error %d %d", {type, errorid}); + f8::MsgQueue::Instance()->PostMsg_r(IM_GGListenerError, + a8::XParams() + .SetParam1(errorid) + ); } void GGListener::Init() @@ -90,6 +95,12 @@ void GGListener::Init() tcp_listener_->bind_address = "0.0.0.0"; tcp_listener_->bind_port = JsonDataMgr::Instance()->GetConf()->At("listen_port")->AsXValue(); tcp_listener_->Open(); + + f8::MsgQueue::Instance()->RegisterCallBack(IM_GGListenerError, + [] (const a8::XParams& param) + { + GGListener::Instance()->OnListenError(param.param1); + }); } void GGListener::UnInit() @@ -145,3 +156,9 @@ long long GGListener::GetSentBytesNum() { return tcp_listener_->sent_bytes_num; } + +void GGListener::OnListenError(int errorid) +{ + a8::XPrintf("GGListeneron_error %d %d", {type, errorid}); + App::Instance()->terminated = true; +} diff --git a/server/gameserver/GGListener.h b/server/gameserver/GGListener.h index f9b3594..1a32e14 100644 --- a/server/gameserver/GGListener.h +++ b/server/gameserver/GGListener.h @@ -8,14 +8,14 @@ namespace a8 class GGListener : public a8::Singleton { - private: +private: GGListener() {}; friend class a8::Singleton; - public: +public: enum { HID = HID_GGListener }; - public: +public: void Init(); void UnInit(); @@ -44,6 +44,9 @@ class GGListener : public a8::Singleton long long GetSentNodeNum(); long long GetSentBytesNum(); - private: +private: + void OnListenError(int errorid); + +private: a8::TcpListener *tcp_listener_ = nullptr; }; diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index cba2b4e..a0d8733 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -14,6 +14,7 @@ enum InnerMesssage_e IM_BSConnDisconnect, IM_LoadConfig, IM_HttpResponse, + IM_GGListenerError }; //网络处理对象