This commit is contained in:
aozhiwei 2023-09-14 15:11:05 +08:00
parent 1f323b7797
commit f047046215

View File

@ -167,12 +167,15 @@ func (this *room) CMLeaveRoom(hdr *f5.MsgHdr, msg *cs.CMLeaveRoom) {
m := this.getMember(hum.GetAccountId())
if m != nil && this.roomState == ROOM_INIT_STATE {
if this.isOwner(hum) {
if len(this.teamUuidHash) < 2 {
nextOwner := this.getNextOwner()
if nextOwner == nil {
this.doDisband(1)
return
} else {
this.removeMember(this.owner.hum.GetAccountId())
this.owner = nextOwner
}
} else {
this.removeMember(this.owner.hum.GetAccountId())
}
notifyMsg := &cs.SMRoomLeaveNotify{}
this.broadcastMsg(notifyMsg)
@ -385,3 +388,10 @@ func (this *room) genTeamId() int32 {
}
return teamId
}
func (this *room) removeMember(accountId string) {
m := this.getMember(accountId)
if m != nil {
delete(this.members, accountId)
}
}