1
This commit is contained in:
parent
051a3a62ca
commit
c2ac2e91fe
@ -10,6 +10,27 @@ import (
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
type LoginRsp struct {
|
||||
Errcode int `json:"errcode"`
|
||||
Errmsg string `json:"errmsg"`
|
||||
Info struct {
|
||||
UserInfo struct {
|
||||
Activated string `json:"activated"`
|
||||
RenameCount string `json:"rename_count"`
|
||||
AccountID string `json:"account_id"`
|
||||
Name string `json:"name"`
|
||||
HeadId string `json:"head_id"`
|
||||
HeroId string `json:"hero_id"`
|
||||
HeadFrame string `json:"head_frame"`
|
||||
} `json:"user_info"`
|
||||
HeroInfo struct {
|
||||
HeroUniId string `json:"hero_uniid"`
|
||||
HeroId string `json:"hero_id"`
|
||||
Quality string `json:"quality"`
|
||||
} `json:"hero"`
|
||||
} `json:"info"`
|
||||
}
|
||||
|
||||
type Team interface {
|
||||
GetTeamUuid() string
|
||||
CanJoin(string) bool
|
||||
|
@ -41,8 +41,8 @@ func (this *player) SendMsg(rspMsg proto.Message) {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *player) init(req *pendingLoginRequest, name string, avatarUrl string, heroId string,
|
||||
headFrame string){
|
||||
func (this *player) init(req *pendingLoginRequest, rsp *common.LoginRsp){
|
||||
/*
|
||||
this.socket = req.hdr.GetSocket()
|
||||
this.accountId = req.msg.GetAccountId()
|
||||
this.sessionId = req.msg.GetSessionId()
|
||||
@ -51,11 +51,11 @@ func (this *player) init(req *pendingLoginRequest, name string, avatarUrl string
|
||||
this.name = name
|
||||
this.avatarUrl = avatarUrl
|
||||
this.heroId = heroId
|
||||
this.headFrame = headFrame
|
||||
this.headFrame = headFrame*/
|
||||
}
|
||||
|
||||
func (this *player) againInit(req *pendingLoginRequest, name string, avatarUrl string, heroId string,
|
||||
headFrame string){
|
||||
func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){
|
||||
/*
|
||||
this.socket = req.hdr.GetSocket()
|
||||
this.accountId = req.msg.GetAccountId()
|
||||
this.sessionId = req.msg.GetSessionId()
|
||||
@ -64,7 +64,7 @@ func (this *player) againInit(req *pendingLoginRequest, name string, avatarUrl s
|
||||
this.name = name
|
||||
this.avatarUrl = avatarUrl
|
||||
this.heroId = heroId
|
||||
this.headFrame = headFrame
|
||||
this.headFrame = headFrame*/
|
||||
}
|
||||
|
||||
func (this *player) GetSocket() f5.WspCliConn {
|
||||
|
@ -111,10 +111,9 @@ func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
|
||||
}
|
||||
params := map[string]string{
|
||||
"c": "User",
|
||||
"a": "info",
|
||||
"a": "getBattleInfo",
|
||||
"account_id": msg.GetAccountId(),
|
||||
"session_id": msg.GetSessionId(),
|
||||
"target_id": msg.GetAccountId(),
|
||||
}
|
||||
url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Config.GetById(0).GetGameapiUrl())
|
||||
f5.GetHttpCliMgr().SendJsStyleRequest(
|
||||
@ -139,19 +138,7 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
|
||||
GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg)
|
||||
return
|
||||
}
|
||||
rspObj := struct {
|
||||
Errcode int `json:"errcode"`
|
||||
Errmsg string `json:"errmsg"`
|
||||
Info struct {
|
||||
Activated string `json:"activated"`
|
||||
RenameCount string `json:"rename_count"`
|
||||
AccountID string `json:"account_id"`
|
||||
Name string `json:"name"`
|
||||
HeadId string `json:"head_id"`
|
||||
HeroId string `json:"hero_id"`
|
||||
HeadFrame string `json:"head_frame"`
|
||||
} `json:"info"`
|
||||
}{}
|
||||
rspObj := common.LoginRsp{}
|
||||
{
|
||||
err := json.Unmarshal([]byte(rsp.GetRawData()), &rspObj)
|
||||
if err != nil {
|
||||
@ -172,7 +159,7 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
|
||||
|
||||
if msg.GetCreateTeamParam() != nil {
|
||||
hum := new(player)
|
||||
hum.init(pendingReq, rspObj.Info.Name, rspObj.Info.HeadId, rspObj.Info.HeroId, rspObj.Info.HeadFrame)
|
||||
hum.init(pendingReq, &rspObj)
|
||||
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
||||
team := GetTeamMgr().CreateTeam(hum, msg)
|
||||
if team == nil {
|
||||
@ -206,19 +193,11 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
|
||||
if hum.socket.IsValid() {
|
||||
delete(this.socketHash, hum.socket)
|
||||
}
|
||||
hum.againInit(pendingReq,
|
||||
rspObj.Info.Name,
|
||||
rspObj.Info.HeadId,
|
||||
rspObj.Info.HeroId,
|
||||
rspObj.Info.HeadFrame)
|
||||
hum.againInit(pendingReq, &rspObj)
|
||||
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
||||
} else {
|
||||
hum := new(player)
|
||||
hum.init(pendingReq,
|
||||
rspObj.Info.Name,
|
||||
rspObj.Info.HeadId,
|
||||
rspObj.Info.HeroId,
|
||||
rspObj.Info.HeadFrame)
|
||||
hum.init(pendingReq, &rspObj)
|
||||
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
||||
team.Join(hum)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user