This commit is contained in:
aozhiwei 2024-03-11 10:55:24 +08:00
parent fa866812b9
commit d55122d764
3 changed files with 21 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import (
)
type Team interface {
GetTeamUuid() string
OnPlayerOffline(Player)
OnPlayerOnline(Player)
}
@ -29,6 +30,7 @@ type Player interface {
GetPing() int32
SendMsg(proto.Message)
IsOnline() bool
GetTeam() Team
}
type PlayerMgr interface {

View File

@ -4,7 +4,7 @@ import (
"cs"
"f5"
"github.com/golang/protobuf/proto"
//"main/common"
"main/common"
. "main/global"
)
@ -20,6 +20,7 @@ type player struct {
heroId string
headFrame string
ping int32
team common.Team
}
func (this *player) SendMsg(rspMsg proto.Message) {
@ -102,3 +103,7 @@ func (this *player) internalSetPing(ping int32) {
this.ping = ping
}
}
func (this *player) GetTeam() common.Team {
return this.team
}

View File

@ -64,6 +64,17 @@ func (this *playerMgr) UnInit() {
}
func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
{
if msg.GetCreateTeamParam() == nil &&
msg.GetJoinTeamParam() == nil {
rspMsg := cs.SMLogin{}
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("params error")
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, &rspMsg)
return
}
}
{
oldHum := this.internalGetPlayerBySocket(hdr.GetSocket())
if oldHum != nil {
@ -71,9 +82,9 @@ func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
rspMsg.Errcode = proto.Int32(0)
rspMsg.Errmsg = proto.String("")
rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo())
rspMsg.TeamUuid = proto.String(oldHum.GetTeam().GetTeamUuid())
oldHum.reBind(hdr.GetSocket())
oldHum.SendMsg(&rspMsg)
return
}
}
@ -119,7 +130,7 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
if pendingReq == nil || pendingReq.reqId != *reqId {
return
}
delete(this.pendingLoginHash, msg.GetAccountId())
defer delete(this.pendingLoginHash, msg.GetAccountId())
rspMsg := cs.SMLogin{}
if rsp.GetErr() != nil {
@ -161,7 +172,6 @@ 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.accountIdHash[hum.GetAccountId()] = hum
this.socketHash[pendingReq.hdr.GetSocket()] = hum
rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo())