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.
76 lines
1.3 KiB
76 lines
1.3 KiB
package jin2 |
|
|
|
import ( |
|
"fmt" |
|
"server/call" |
|
"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 = Jin2 |
|
} |
|
|
|
func (s *Sub) Init() { |
|
API = APITest |
|
AgentMap = AgentMapTest |
|
if config.GetBase().Release { |
|
API = APIRlease |
|
AgentMap = AgentMapRelease |
|
} |
|
} |
|
|
|
type EnterReq struct { |
|
UserID string |
|
GameID string |
|
Language string |
|
} |
|
|
|
type EnterResp struct { |
|
Code int |
|
Error string |
|
Data struct { |
|
URL string `json:"Url"` |
|
} |
|
} |
|
|
|
func (s *Sub) EnterGame() string { |
|
log.Debug("jin2 enter game, %+v", *s.Base.EnterGameReq) |
|
providerID := s.Base.EnterGameReq.ProviderID |
|
gameID := s.Base.EnterGameReq.GameID |
|
game := call.GetGameListByByID(providerID, gameID) |
|
if game == nil { |
|
return "" |
|
} |
|
|
|
req := &EnterReq{ |
|
UserID: call.GetProviderUserName(fmt.Sprintf("%d", s.Base.UID)), |
|
GameID: game.GameCode, |
|
Language: "en", |
|
} |
|
|
|
var resp EnterResp |
|
headers := map[string]string{ |
|
"AppID": AgentMap.MchId, |
|
"AppSecret": AgentMap.Key, |
|
} |
|
err := util.HttpPost(API, req, &resp, headers) |
|
if err != nil { |
|
log.Error("err:%v", err) |
|
return "" |
|
} |
|
if resp.Data.URL == "" { |
|
log.Error("err:%+v", resp) |
|
return "" |
|
} |
|
|
|
return resp.Data.URL |
|
}
|
|
|