1
This commit is contained in:
parent
62ef4c3a26
commit
2ee42ed3b1
@ -13,6 +13,9 @@ type player struct {
|
||||
socket f5.WspCliConn
|
||||
accountId string
|
||||
sessionId string
|
||||
name string
|
||||
avatarUrl string
|
||||
heroId int32
|
||||
ping int32
|
||||
room common.Room
|
||||
}
|
||||
@ -35,10 +38,13 @@ func (this *player) SetRoom(room common.Room) {
|
||||
this.room = room
|
||||
}
|
||||
|
||||
func (this *player) init(req *pendingLoginRequest){
|
||||
func (this *player) init(req *pendingLoginRequest, name string, avatarUrl string, heroId int32){
|
||||
this.socket = req.hdr.GetSocket()
|
||||
this.accountId = req.msg.GetAccountId()
|
||||
this.sessionId = req.msg.GetSessionId()
|
||||
this.name = name
|
||||
this.avatarUrl = avatarUrl
|
||||
this.heroId = heroId
|
||||
}
|
||||
|
||||
func (this *player) onOffline(){
|
||||
@ -57,15 +63,15 @@ func (this *player) reBind(socket f5.WspCliConn) {
|
||||
}
|
||||
|
||||
func (this *player) GetName() string {
|
||||
return ""
|
||||
return this.name
|
||||
}
|
||||
|
||||
func (this *player) GetAvatarUrl() string {
|
||||
return ""
|
||||
return this.avatarUrl
|
||||
}
|
||||
|
||||
func (this *player) GetHeroId() int32 {
|
||||
return 0
|
||||
return this.heroId
|
||||
}
|
||||
|
||||
func (this *player) GetPing() int32 {
|
||||
|
@ -126,7 +126,7 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
|
||||
GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg)
|
||||
return
|
||||
}
|
||||
resObj := struct {
|
||||
rspObj := struct {
|
||||
Errcode int `json:"errcode"`
|
||||
Errmsg string `json:"errmsg"`
|
||||
Info struct {
|
||||
@ -134,10 +134,12 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
|
||||
RenameCount string `json:"rename_count"`
|
||||
AccountID string `json:"account_id"`
|
||||
Name string `json:"name"`
|
||||
HeadId int32 `json:"head_id"`
|
||||
HeroId int32 `json:"hero"`
|
||||
} `json:"info"`
|
||||
}{}
|
||||
{
|
||||
err := json.Unmarshal([]byte(rsp.GetRawData()), &resObj)
|
||||
err := json.Unmarshal([]byte(rsp.GetRawData()), &rspObj)
|
||||
if err != nil {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("invalid session_id")
|
||||
@ -146,16 +148,16 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
|
||||
return
|
||||
}
|
||||
}
|
||||
if resObj.Errcode != 0 {
|
||||
if rspObj.Errcode != 0 {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("invalid session_id")
|
||||
GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg)
|
||||
f5.GetSysLog().Warning("game2006api login auth errcode:%d", resObj.Errcode)
|
||||
f5.GetSysLog().Warning("game2006api login auth errcode:%d", rspObj.Errcode)
|
||||
return
|
||||
}
|
||||
|
||||
hum := new(player)
|
||||
hum.init(pendingReq)
|
||||
hum.init(pendingReq, rspObj.Info.Name, q5.ToString(rspObj.Info.HeadId), rspObj.Info.HeroId)
|
||||
this.accountIdHash[hum.GetAccountId()] = hum
|
||||
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user