This commit is contained in:
aozhiwei 2024-03-21 15:54:08 +08:00
parent f99e570d50
commit ba8d674c36

View File

@ -118,15 +118,16 @@ func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
"target_id": msg.GetAccountId(), "target_id": msg.GetAccountId(),
} }
url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Config.GetById(0).GetGameapiUrl()) url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Config.GetById(0).GetGameapiUrl())
rspObj := &common.LoginRsp{}
f5.GetHttpCliMgr().SendJsStyleRequest( f5.GetHttpCliMgr().SendJsStyleRequest(
url, url,
params, params,
func(rsp f5.HttpCliResponse) { func(rsp f5.HttpCliResponse) {
this.apiAuthCb(hdr, msg, rsp, reqId) this.apiAuthCb(hdr, msg, reqId, rsp, rspObj)
}) })
} }
func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCliResponse, reqId int64) { func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, reqId int64, rsp f5.HttpCliResponse, rspObj *common.LoginRsp) {
pendingReq := this.getPendingRequest(msg.GetAccountId()) pendingReq := this.getPendingRequest(msg.GetAccountId())
if pendingReq == nil || pendingReq.reqId != reqId { if pendingReq == nil || pendingReq.reqId != reqId {
return return
@ -141,7 +142,6 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
f5.GetSysLog().Info("Api服务器JSON 解析错误1\n") f5.GetSysLog().Info("Api服务器JSON 解析错误1\n")
return return
} }
rspObj := common.LoginRsp{}
err := json.Unmarshal([]byte(rsp.GetRawData()), &rspObj) err := json.Unmarshal([]byte(rsp.GetRawData()), &rspObj)
if err != nil { if err != nil {
rspMsg.Errcode = proto.Int32(2) rspMsg.Errcode = proto.Int32(2)
@ -158,7 +158,7 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
return return
} }
hum := newPlayer() hum := newPlayer()
hum.init(pendingReq, &rspObj) hum.init(pendingReq, rspObj)
this.accountIdHash[hum.GetAccountId()] = hum this.accountIdHash[hum.GetAccountId()] = hum
this.socketHash[pendingReq.hdr.GetSocket()] = hum this.socketHash[pendingReq.hdr.GetSocket()] = hum
rspMsg.AccountId = proto.String(rspObj.Info.AccountID) rspMsg.AccountId = proto.String(rspObj.Info.AccountID)