1
This commit is contained in:
parent
413fe047f5
commit
257dde8f10
@ -12,12 +12,15 @@ import (
|
|||||||
|
|
||||||
type Team interface {
|
type Team interface {
|
||||||
GetTeamUuid() string
|
GetTeamUuid() string
|
||||||
|
CanJoin(string) bool
|
||||||
|
Join(Player) bool
|
||||||
OnPlayerOffline(Player)
|
OnPlayerOffline(Player)
|
||||||
OnPlayerOnline(Player)
|
OnPlayerOnline(Player)
|
||||||
}
|
}
|
||||||
|
|
||||||
type TeamMgr interface {
|
type TeamMgr interface {
|
||||||
ProcessCMMsg(*cs.CsNetMsgHandler, *f5.MsgHdr)
|
ProcessCMMsg(*cs.CsNetMsgHandler, *f5.MsgHdr)
|
||||||
|
CreateTeam(Player) Team
|
||||||
GetTeamByUuid(string) Team
|
GetTeamByUuid(string) Team
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,15 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
|
|||||||
hum := new(player)
|
hum := new(player)
|
||||||
hum.init(pendingReq, rspObj.Info.Name, rspObj.Info.HeadId, rspObj.Info.HeroId, rspObj.Info.HeadFrame)
|
hum.init(pendingReq, rspObj.Info.Name, rspObj.Info.HeadId, rspObj.Info.HeroId, rspObj.Info.HeadFrame)
|
||||||
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
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())
|
rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo())
|
||||||
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, &rspMsg)
|
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, &rspMsg)
|
||||||
} else if msg.GetJoinTeamParam() != nil {
|
} 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.Errcode = proto.Int32(101)
|
||||||
rspMsg.Errmsg = proto.String("join team error team not found")
|
rspMsg.Errmsg = proto.String("join team error team not found")
|
||||||
GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg)
|
GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg)
|
||||||
f5.GetSysLog().Warning("game2006api login auth errcode:%d", rspObj.Errcode)
|
|
||||||
return
|
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 {
|
} else {
|
||||||
panic("CMLogin Param error")
|
panic("CMLogin Param error")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user