1
This commit is contained in:
parent
051a3a62ca
commit
c2ac2e91fe
@ -10,6 +10,27 @@ import (
|
|||||||
proto "github.com/golang/protobuf/proto"
|
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 {
|
type Team interface {
|
||||||
GetTeamUuid() string
|
GetTeamUuid() string
|
||||||
CanJoin(string) bool
|
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,
|
func (this *player) init(req *pendingLoginRequest, rsp *common.LoginRsp){
|
||||||
headFrame string){
|
/*
|
||||||
this.socket = req.hdr.GetSocket()
|
this.socket = req.hdr.GetSocket()
|
||||||
this.accountId = req.msg.GetAccountId()
|
this.accountId = req.msg.GetAccountId()
|
||||||
this.sessionId = req.msg.GetSessionId()
|
this.sessionId = req.msg.GetSessionId()
|
||||||
@ -51,11 +51,11 @@ func (this *player) init(req *pendingLoginRequest, name string, avatarUrl string
|
|||||||
this.name = name
|
this.name = name
|
||||||
this.avatarUrl = avatarUrl
|
this.avatarUrl = avatarUrl
|
||||||
this.heroId = heroId
|
this.heroId = heroId
|
||||||
this.headFrame = headFrame
|
this.headFrame = headFrame*/
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *player) againInit(req *pendingLoginRequest, name string, avatarUrl string, heroId string,
|
func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){
|
||||||
headFrame string){
|
/*
|
||||||
this.socket = req.hdr.GetSocket()
|
this.socket = req.hdr.GetSocket()
|
||||||
this.accountId = req.msg.GetAccountId()
|
this.accountId = req.msg.GetAccountId()
|
||||||
this.sessionId = req.msg.GetSessionId()
|
this.sessionId = req.msg.GetSessionId()
|
||||||
@ -64,7 +64,7 @@ func (this *player) againInit(req *pendingLoginRequest, name string, avatarUrl s
|
|||||||
this.name = name
|
this.name = name
|
||||||
this.avatarUrl = avatarUrl
|
this.avatarUrl = avatarUrl
|
||||||
this.heroId = heroId
|
this.heroId = heroId
|
||||||
this.headFrame = headFrame
|
this.headFrame = headFrame*/
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *player) GetSocket() f5.WspCliConn {
|
func (this *player) GetSocket() f5.WspCliConn {
|
||||||
|
@ -111,10 +111,9 @@ func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
|
|||||||
}
|
}
|
||||||
params := map[string]string{
|
params := map[string]string{
|
||||||
"c": "User",
|
"c": "User",
|
||||||
"a": "info",
|
"a": "getBattleInfo",
|
||||||
"account_id": msg.GetAccountId(),
|
"account_id": msg.GetAccountId(),
|
||||||
"session_id": msg.GetSessionId(),
|
"session_id": msg.GetSessionId(),
|
||||||
"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())
|
||||||
f5.GetHttpCliMgr().SendJsStyleRequest(
|
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)
|
GetWspListener().SendProxyMsg(pendingReq.hdr.Conn, pendingReq.hdr.SocketHandle, &rspMsg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rspObj := struct {
|
rspObj := common.LoginRsp{}
|
||||||
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"`
|
|
||||||
}{}
|
|
||||||
{
|
{
|
||||||
err := json.Unmarshal([]byte(rsp.GetRawData()), &rspObj)
|
err := json.Unmarshal([]byte(rsp.GetRawData()), &rspObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -172,7 +159,7 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
|
|||||||
|
|
||||||
if msg.GetCreateTeamParam() != nil {
|
if msg.GetCreateTeamParam() != nil {
|
||||||
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)
|
||||||
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
||||||
team := GetTeamMgr().CreateTeam(hum, msg)
|
team := GetTeamMgr().CreateTeam(hum, msg)
|
||||||
if team == nil {
|
if team == nil {
|
||||||
@ -206,19 +193,11 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
|
|||||||
if hum.socket.IsValid() {
|
if hum.socket.IsValid() {
|
||||||
delete(this.socketHash, hum.socket)
|
delete(this.socketHash, hum.socket)
|
||||||
}
|
}
|
||||||
hum.againInit(pendingReq,
|
hum.againInit(pendingReq, &rspObj)
|
||||||
rspObj.Info.Name,
|
|
||||||
rspObj.Info.HeadId,
|
|
||||||
rspObj.Info.HeroId,
|
|
||||||
rspObj.Info.HeadFrame)
|
|
||||||
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
||||||
} else {
|
} else {
|
||||||
hum := new(player)
|
hum := new(player)
|
||||||
hum.init(pendingReq,
|
hum.init(pendingReq, &rspObj)
|
||||||
rspObj.Info.Name,
|
|
||||||
rspObj.Info.HeadId,
|
|
||||||
rspObj.Info.HeroId,
|
|
||||||
rspObj.Info.HeadFrame)
|
|
||||||
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
this.socketHash[pendingReq.hdr.GetSocket()] = hum
|
||||||
team.Join(hum)
|
team.Join(hum)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user