添加监听失败处理
This commit is contained in:
parent
82bbd8bdbb
commit
4120ac569f
@ -5,6 +5,7 @@
|
||||
#include <a8/tcplistener.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -44,6 +44,9 @@ class GGListener : public a8::Singleton<GGListener>
|
||||
long long GetSentNodeNum();
|
||||
long long GetSentBytesNum();
|
||||
|
||||
private:
|
||||
void OnListenError(int errorid);
|
||||
|
||||
private:
|
||||
a8::TcpListener *tcp_listener_ = nullptr;
|
||||
};
|
||||
|
@ -14,6 +14,7 @@ enum InnerMesssage_e
|
||||
IM_BSConnDisconnect,
|
||||
IM_LoadConfig,
|
||||
IM_HttpResponse,
|
||||
IM_GGListenerError
|
||||
};
|
||||
|
||||
//网络处理对象
|
||||
|
Loading…
x
Reference in New Issue
Block a user