diff --git a/server/gameserver/GGListener.cc b/server/gameserver/GGListener.cc index a9a8df4..df175a0 100644 --- a/server/gameserver/GGListener.cc +++ b/server/gameserver/GGListener.cc @@ -12,6 +12,8 @@ #include "jsondatamgr.h" #include "cs_proto.pb.h" #include "cs_msgid.pb.h" +#include "ss_proto.pb.h" +#include "ss_msgid.pb.h" #include "handlermgr.h" class GCClientSession: public a8::MixedSession @@ -137,6 +139,12 @@ void GGListener::ForceCloseClient(int sockhandle) tcp_listener_->ForceCloseClient(sockhandle); } +void GGListener::ForceCloseChildSocket(int sockhandle) +{ + ss::SS_ForceCloseSocket msg; + SendProxyMsg(sockhandle, msg); +} + void GGListener::MarkClient(int sockhandle, bool is_active) { tcp_listener_->MarkClient(sockhandle, is_active); diff --git a/server/gameserver/GGListener.h b/server/gameserver/GGListener.h index 1a32e14..29b3081 100644 --- a/server/gameserver/GGListener.h +++ b/server/gameserver/GGListener.h @@ -39,6 +39,7 @@ public: const char* file = nullptr, int lineno = 0, int error_param = 0); void ForceCloseClient(int sockhandle); + void ForceCloseChildSocket(int sockhandle); void MarkClient(int sockhandle, bool is_active); long long GetSendNodeNum(); long long GetSentNodeNum(); diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index c24c4d2..37fc02a 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -51,7 +51,30 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg) abort(); } if (RoomNum() >= ROOM_NUM_LIMIT) { - return; + { + cs::SMJoinedNotify notifymsg; + notifymsg.set_error_code(2); + GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg); + } + { + a8::Timer::Instance()->AddDeadLineTimer(1000 * 2, + a8::XParams() + .SetSender(hdr.socket_handle), + [] (const a8::XParams& param) + { + GGListener::Instance()->ForceCloseChildSocket(param.sender); + }); + } + a8::UdpLog::Instance()->Warning("room is full! accountid:%s max_mainloop_rundelay:%d " + "room_num:%d player_num:%d online_num:%d", + { + msg.account_id(), + App::Instance()->perf.max_run_delay_time, + RoomMgr::Instance()->RoomNum(), + App::Instance()->perf.entity_num[ET_Player], + PlayerMgr::Instance()->OnlineNum(), + }); + return; } Room* room = GetJoinableRoom(msg.account_id()); if (!room) {