This commit is contained in:
aozhiwei 2023-09-16 13:23:31 +08:00
parent 9d3f817dc3
commit 6d5fb42a9b
5 changed files with 79 additions and 1 deletions

View File

@ -1,5 +1,6 @@
{
"gameapi_url": "https://game2006api-test.kingsome.cn",
"auto_start_time": 3600,
"game_start_notify_time": 20
"game_start_notify_time": 20,
"delay_delete_time": 60
}

View File

@ -49,6 +49,8 @@ type MsgHandler interface {
CMKickoutTeam(*f5.MsgHdr, *CMKickoutTeam)
CMKickoutMember(*f5.MsgHdr, *CMKickoutMember)
CMCloseNotify(*f5.MsgHdr, *CMCloseNotify)
CMReportPingValue(*f5.MsgHdr, *CMReportPingValue)
CMGetCurrentRoom(*f5.MsgHdr, *CMGetCurrentRoom)
}
func (this *MsgHandlerImpl) CMPing(hdr *f5.MsgHdr, msg *CMPing) {
@ -93,6 +95,12 @@ func (this *MsgHandlerImpl) CMKickoutMember(hdr *f5.MsgHdr, msg *CMKickoutMember
func (this *MsgHandlerImpl) CMCloseNotify(hdr *f5.MsgHdr, msg *CMCloseNotify) {
}
func (this *MsgHandlerImpl) CMReportPingValue(hdr *f5.MsgHdr, msg *CMReportPingValue) {
}
func (this *MsgHandlerImpl) CMGetCurrentRoom(hdr *f5.MsgHdr, msg *CMGetCurrentRoom) {
}
func (this *CMPing) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMPing)
}
@ -193,6 +201,18 @@ func (this *CMCloseNotify) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMCloseNotify)
}
func (this *CMReportPingValue) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMReportPingValue)
}
func (this *CMGetCurrentRoom) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMGetCurrentRoom)
}
func (this *SMGetCurrentRoom) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMGetCurrentRoom)
}
func (this *SMRoomMemberChangeNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMRoomMemberChangeNotify)
}
@ -387,4 +407,28 @@ func init() {
},
}
handlers[int(CMMessageIdE__CMReportPingValue)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMReportPingValue),
ParseCb: func (data []byte) interface{} {
msg := &CMReportPingValue{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMReportPingValue(hdr, hdr.Msg.(*CMReportPingValue))
},
}
handlers[int(CMMessageIdE__CMGetCurrentRoom)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMGetCurrentRoom),
ParseCb: func (data []byte) interface{} {
msg := &CMGetCurrentRoom{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMGetCurrentRoom(hdr, hdr.Msg.(*CMGetCurrentRoom))
},
}
}

View File

@ -48,6 +48,7 @@ type Config struct {
gameapi_url string
auto_start_time int32
game_start_notify_time int32
delay_delete_time int32
_flags1_ uint64
_flags2_ uint64
@ -205,6 +206,14 @@ func (this *Config) HasGameStartNotifyTime() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *Config) GetDelayDeleteTime() int32 {
return this.delay_delete_time
}
func (this *Config) HasDelayDeleteTime() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *HallCluster) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
@ -238,4 +247,5 @@ func (this *Config) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.auto_start_time, "auto_start_time", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.game_start_notify_time, "game_start_notify_time", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.delay_delete_time, "delay_delete_time", &this._flags1_, 4, kv)
}

View File

@ -39,4 +39,5 @@ message Config
optional string gameapi_url = 1;
optional int32 auto_start_time = 2;
optional int32 game_start_notify_time = 3;
optional int32 delay_delete_time = 4;
}

View File

@ -32,6 +32,7 @@ type room struct {
teamIdHash map[int32]*team
members map[string]*member
startTimer *f5.TimerWp
delayDeleteTimer *f5.TimerWp
attacher *f5.TimerAttacher
gameStartNotifyMsg *cs.SMRoomGameStartNotify
}
@ -51,6 +52,12 @@ func (this *room) init(roomId string, roomIdx int64,
}
func (this *room) unInit() {
for ; len(this.teamUuidHash) > 0; {
for _, t := range(this.teamUuidHash) {
t.unInit()
break
}
}
this.attacher.ClearTimers()
this.entry.DelInit()
delete(_roomMgr.idHash, this.roomId)
@ -317,6 +324,7 @@ func (this *room) doDisband(reason int32) {
m.hum.SendMsg(notifyMsg)
}
}
this.delayDeleteRoom()
}
func (this *room) doStart(reason int32) {
@ -334,6 +342,7 @@ func (this *room) doStart(reason int32) {
}
},
this.attacher)
this.delayDeleteRoom()
}
func (this *room) viewable() bool {
@ -472,6 +481,19 @@ func (this *room) notifyRoomInfo() {
this.broadcastMsg(notifyMsg)
}
func (this *room) delayDeleteRoom() {
if this.delayDeleteTimer != nil {
panic("errror dealyDeleteRoom")
}
this.delayDeleteTimer = f5.GetTimer().SetTimeoutExWp(
1000 * mt.Table.Config.Get().GetDelayDeleteTime(),
func (e int32, args *q5.Args) {
if e == q5.TIMER_EXEC_EVENT {
this.unInit()
}
},
this.attacher)
}
func newRoom() *room {
r := new(room)