This commit is contained in:
aozhiwei 2023-09-08 13:52:42 +08:00
parent e3307f7e64
commit 3a216a6795
2 changed files with 12 additions and 9 deletions

View File

@ -27,3 +27,10 @@ func (this *player) SendMsg(rspMsg proto.Message) {
func (this *player) GetRoom() *common.Room { func (this *player) GetRoom() *common.Room {
return this.room return this.room
} }
func (this *player) init(req *pendingLoginRequest){
this.socket = req.hdr.GetSocket()
this.accountId = req.msg.GetAccountId()
this.sessionId = req.msg.GetSessionId()
}

View File

@ -148,14 +148,10 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
return return
} }
player := player{ hum := new(player)
socket: hdr.GetSocket(), hum.init(pendingReq)
accountId: msg.GetAccountId(), this.addPlayer(hum)
sessionId: msg.GetAccountId(), this.addSocketHash(hdr.GetSocket(), hum)
}
// Add to online user
this.addplayer(&player)
this.addSocketHash(hdr.GetSocket(), &player)
serverInfo := mt.Table.HallCluster.GetIp() + ":" + q5.ToString(mt.Table.HallCluster.GetListenPort()) serverInfo := mt.Table.HallCluster.GetIp() + ":" + q5.ToString(mt.Table.HallCluster.GetListenPort())
rspMsg.ServerInfo = &serverInfo rspMsg.ServerInfo = &serverInfo
@ -186,7 +182,7 @@ func (this *playerMgr) GetPlayers() map[string]*player {
return this.accountIdHash return this.accountIdHash
} }
func (this *playerMgr) addplayer(p *player) { func (this *playerMgr) addPlayer(p *player) {
this.accountIdHash[p.accountId] = p this.accountIdHash[p.accountId] = p
} }