1
This commit is contained in:
parent
fa866812b9
commit
d55122d764
@ -11,6 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Team interface {
|
type Team interface {
|
||||||
|
GetTeamUuid() string
|
||||||
OnPlayerOffline(Player)
|
OnPlayerOffline(Player)
|
||||||
OnPlayerOnline(Player)
|
OnPlayerOnline(Player)
|
||||||
}
|
}
|
||||||
@ -29,6 +30,7 @@ type Player interface {
|
|||||||
GetPing() int32
|
GetPing() int32
|
||||||
SendMsg(proto.Message)
|
SendMsg(proto.Message)
|
||||||
IsOnline() bool
|
IsOnline() bool
|
||||||
|
GetTeam() Team
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlayerMgr interface {
|
type PlayerMgr interface {
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"cs"
|
"cs"
|
||||||
"f5"
|
"f5"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
//"main/common"
|
"main/common"
|
||||||
. "main/global"
|
. "main/global"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,6 +20,7 @@ type player struct {
|
|||||||
heroId string
|
heroId string
|
||||||
headFrame string
|
headFrame string
|
||||||
ping int32
|
ping int32
|
||||||
|
team common.Team
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *player) SendMsg(rspMsg proto.Message) {
|
func (this *player) SendMsg(rspMsg proto.Message) {
|
||||||
@ -102,3 +103,7 @@ func (this *player) internalSetPing(ping int32) {
|
|||||||
this.ping = ping
|
this.ping = ping
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *player) GetTeam() common.Team {
|
||||||
|
return this.team
|
||||||
|
}
|
||||||
|
@ -64,6 +64,17 @@ func (this *playerMgr) UnInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
|
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())
|
oldHum := this.internalGetPlayerBySocket(hdr.GetSocket())
|
||||||
if oldHum != nil {
|
if oldHum != nil {
|
||||||
@ -71,9 +82,9 @@ func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
|
|||||||
rspMsg.Errcode = proto.Int32(0)
|
rspMsg.Errcode = proto.Int32(0)
|
||||||
rspMsg.Errmsg = proto.String("")
|
rspMsg.Errmsg = proto.String("")
|
||||||
rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo())
|
rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo())
|
||||||
|
rspMsg.TeamUuid = proto.String(oldHum.GetTeam().GetTeamUuid())
|
||||||
oldHum.reBind(hdr.GetSocket())
|
oldHum.reBind(hdr.GetSocket())
|
||||||
oldHum.SendMsg(&rspMsg)
|
oldHum.SendMsg(&rspMsg)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +130,7 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
|
|||||||
if pendingReq == nil || pendingReq.reqId != *reqId {
|
if pendingReq == nil || pendingReq.reqId != *reqId {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
delete(this.pendingLoginHash, msg.GetAccountId())
|
defer delete(this.pendingLoginHash, msg.GetAccountId())
|
||||||
|
|
||||||
rspMsg := cs.SMLogin{}
|
rspMsg := cs.SMLogin{}
|
||||||
if rsp.GetErr() != nil {
|
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 := 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.accountIdHash[hum.GetAccountId()] = hum
|
|
||||||
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
||||||
|
|
||||||
rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo())
|
rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user