1
This commit is contained in:
parent
47e6a14480
commit
b22f82c0e3
@ -103,38 +103,18 @@ void RoomMgr::Update(int delta_time)
|
||||
|
||||
void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
{
|
||||
RoomType_e self_room_type = GetHumanRoomType(msg);
|
||||
if (IsLimitJoin()) {
|
||||
{
|
||||
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(),
|
||||
});
|
||||
JoinErrorHandle(msg, 2, hdr.socket_handle);
|
||||
return;
|
||||
}
|
||||
RoomType_e self_room_type = GetHumanRoomType(msg);
|
||||
Room* room = GetJoinableRoom(msg, self_room_type);
|
||||
if (!room) {
|
||||
JoinErrorHandle(msg, 3, hdr.socket_handle);
|
||||
return;
|
||||
}
|
||||
Player* hum = PlayerMgr::Instance()->CreatePlayerByCMJoin(hdr.ip_saddr,
|
||||
Player* hum = PlayerMgr::Instance()->
|
||||
CreatePlayerByCMJoin(hdr.ip_saddr,
|
||||
hdr.socket_handle,
|
||||
msg);
|
||||
hum->meta = hum_meta_;
|
||||
@ -498,7 +478,7 @@ int RoomMgr::AllocRoomIdx()
|
||||
Room* RoomMgr::CreateRoom(RoomType_e room_type)
|
||||
{
|
||||
int room_idx = AllocRoomIdx();
|
||||
if (room_idx == -1) {
|
||||
if (room_idx < 1) {
|
||||
return nullptr;
|
||||
}
|
||||
Room* room = new Room();
|
||||
@ -523,3 +503,32 @@ Room* RoomMgr::CreateRoom(RoomType_e room_type)
|
||||
room_idx_hash_[room->room_idx] = room;
|
||||
return room;
|
||||
}
|
||||
|
||||
void RoomMgr::JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle)
|
||||
{
|
||||
{
|
||||
cs::SMJoinedNotify notifymsg;
|
||||
notifymsg.set_error_code(error_code);
|
||||
GGListener::Instance()->SendToClient(socket_handle, 0, notifymsg);
|
||||
}
|
||||
{
|
||||
a8::Timer::Instance()->
|
||||
AddDeadLineTimer(1000 * 2,
|
||||
a8::XParams()
|
||||
.SetSender(socket_handle),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
GGListener::Instance()->ForceCloseChildSocket(param.sender);
|
||||
});
|
||||
}
|
||||
a8::UdpLog::Instance()->Warning("join error errcode:%d accountid:%s max_mainloop_rundelay:%d "
|
||||
"room_num:%d player_num:%d online_num:%d",
|
||||
{
|
||||
error_code,
|
||||
msg.account_id(),
|
||||
App::Instance()->perf.max_run_delay_time,
|
||||
RoomMgr::Instance()->RoomNum(),
|
||||
App::Instance()->perf.entity_num[ET_Player],
|
||||
PlayerMgr::Instance()->OnlineNum(),
|
||||
});
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
||||
int AllocUniid();
|
||||
int AllocRoomIdx();
|
||||
Room* CreateRoom(RoomType_e room_type);
|
||||
void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle);
|
||||
|
||||
private:
|
||||
std::map<long long, Room*> inactive_room_hash_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user