This commit is contained in:
aozhiwei 2024-03-11 15:59:57 +08:00
parent 413fe047f5
commit 257dde8f10
2 changed files with 26 additions and 1 deletions

View File

@ -12,12 +12,15 @@ import (
type Team interface {
GetTeamUuid() string
CanJoin(string) bool
Join(Player) bool
OnPlayerOffline(Player)
OnPlayerOnline(Player)
}
type TeamMgr interface {
ProcessCMMsg(*cs.CsNetMsgHandler, *f5.MsgHdr)
CreateTeam(Player) Team
GetTeamByUuid(string) Team
}

View File

@ -174,7 +174,15 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
hum := new(player)
hum.init(pendingReq, rspObj.Info.Name, rspObj.Info.HeadId, rspObj.Info.HeroId, rspObj.Info.HeadFrame)
this.socketHash[pendingReq.hdr.GetSocket()] = hum
team := GetTeamMgr().CreateTeam(hum)
if team == nil {
rspMsg.Errcode = proto.Int32(102)
rspMsg.Errmsg = proto.String("create team error")
GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg)
return
}
rspMsg.TeamUuid = proto.String(team.GetTeamUuid())
rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo())
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, &rspMsg)
} else if msg.GetJoinTeamParam() != nil {
@ -183,9 +191,23 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
rspMsg.Errcode = proto.Int32(101)
rspMsg.Errmsg = proto.String("join team error team not found")
GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg)
f5.GetSysLog().Warning("game2006api login auth errcode:%d", rspObj.Errcode)
return
}
if !team.CanJoin(msg.GetAccountId()) {
rspMsg.Errcode = proto.Int32(103)
rspMsg.Errmsg = proto.String("join team error")
GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg)
return
}
hum := new(player)
hum.init(pendingReq, rspObj.Info.Name, rspObj.Info.HeadId, rspObj.Info.HeroId, rspObj.Info.HeadFrame)
this.socketHash[pendingReq.hdr.GetSocket()] = hum
team.Join(hum)
rspMsg.TeamUuid = proto.String(team.GetTeamUuid())
rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo())
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, &rspMsg)
} else {
panic("CMLogin Param error")
}