You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.6 KiB
82 lines
1.6 KiB
package tada |
|
|
|
import ( |
|
"fmt" |
|
"server/call" |
|
"server/common" |
|
"server/config" |
|
"server/modules/web/providers/base" |
|
"server/util" |
|
|
|
"github.com/liangdas/mqant/log" |
|
) |
|
|
|
type Sub struct { |
|
Base *base.Base |
|
} |
|
|
|
func NewSub(base *base.Base) { |
|
base.Sub = &Sub{Base: base} |
|
base.SubInitRouter = Tada |
|
} |
|
|
|
func (s *Sub) Init() { |
|
} |
|
|
|
type CommonResp struct { |
|
ErrorCode int |
|
Message string |
|
Data interface{} |
|
} |
|
|
|
type EnterGameReq struct { |
|
Token string |
|
GameId int `json:"GameId"` |
|
Lang string |
|
} |
|
|
|
func (s *Sub) EnterGame() string { |
|
lang := s.Base.EnterGameReq.Lang |
|
isDemo := s.Base.EnterGameReq.IsDemo |
|
gameid := s.Base.EnterGameReq.GameID |
|
token := common.GetProviderUserToken(s.Base.EnterGameReq.Token) |
|
|
|
reqLang := "en-US" |
|
if lang == "pt" { |
|
reqLang = "pt-BR" |
|
} |
|
channel := call.GetChannelByID(s.Base.ChannelID) |
|
homeURL := "" |
|
if channel != nil && channel.URL != "" { |
|
homeURL = "HomeUrl=https://www." + channel.URL |
|
} |
|
if isDemo { |
|
ret := "https" + fmt.Sprintf("%s/%d/%s", DemoURL, gameid, reqLang) |
|
if homeURL != "" { |
|
ret += "?" + homeURL |
|
} |
|
return ret |
|
} |
|
req := &EnterGameReq{ |
|
Token: token, |
|
GameId: gameid, |
|
Lang: reqLang, |
|
} |
|
url := APITest |
|
if config.GetBase().Release { |
|
url = APIURL |
|
} |
|
url += LoginAPI |
|
reqURL := fmt.Sprintf("%s?Token=%s&GameId=%d&Lang=%s&AgentId=%s&Key=%s", url, token, gameid, reqLang, AgentID, GetSignKey(req)) |
|
if homeURL != "" { |
|
reqURL += "&" + homeURL |
|
} |
|
log.Debug("enter tada:%+v,url:%s", *req, reqURL) |
|
ret := new(CommonResp) |
|
util.HttpGet(reqURL, &ret) |
|
log.Debug("tada resp:%+v", ret) |
|
if str, ok := ret.Data.(string); ok { |
|
return str |
|
} |
|
return "" |
|
}
|
|
|