diff --git a/mgrsrv/api/webapi_worldsrv.go b/mgrsrv/api/webapi_worldsrv.go index cc232e2..390557a 100644 --- a/mgrsrv/api/webapi_worldsrv.go +++ b/mgrsrv/api/webapi_worldsrv.go @@ -30,7 +30,6 @@ import ( const ( WEBAPI_TRANSACTE_EVENT int = iota WEBAPI_TRANSACTE_RESPONSE - PLATFORMAPPKEY = "PLATFORMAPPKEYtest123" ) var WebApiStats = new(sync.Map) @@ -159,7 +158,7 @@ func PlatformSrvApi(rw http.ResponseWriter, req *http.Request) { params := make(map[string]string) json.Unmarshal(data, ¶ms) - realSign := webapi.MD5Params(params, PLATFORMAPPKEY, "sign") + realSign := webapi.MD5Params(params, webapi.Config.GameApiKey, "sign") sign := params["sign"] if realSign != sign { diff --git a/mgrsrv/config.json b/mgrsrv/config.json index 3b295a6..a919052 100644 --- a/mgrsrv/config.json +++ b/mgrsrv/config.json @@ -100,5 +100,9 @@ "common": { "AppId": "5c56d1644966f078bfb90c71", "IsDevMode": true + }, + "webapi": { + "GameApiURL": "http://103.39.231.66:1099/api/game_srv/platform_config", + "GameApiKey": "PLATFORMAPPKEYtest123" } } \ No newline at end of file diff --git a/webapi/config.go b/webapi/config.go index 889eed9..72f09f6 100644 --- a/webapi/config.go +++ b/webapi/config.go @@ -12,6 +12,7 @@ var ( type Configuration struct { GameApiURL string + GameApiKey string } func (this *Configuration) Name() string { diff --git a/webapi/deprecated.go b/webapi/deprecated.go index bbffa29..eb6be8e 100644 --- a/webapi/deprecated.go +++ b/webapi/deprecated.go @@ -237,3 +237,13 @@ func API_GetActConfig(appId string) ([]byte, error) { func ApiGetInviteLink(appId string, body proto.Message) ([]byte, error) { return postRequest(appId, "/get_invite_link", nil, body, "http", DEFAULT_TIMEOUT) } + +// 平台登录返回 +type PlatfromGameLoginRsp struct { + Code int `json:"code"` + Data struct { + Url string `json:"url"` + } `json:"data"` + Message string `json:"message"` + Success bool `json:"success"` +} diff --git a/worldsrv/action_login.go b/worldsrv/action_login.go index ac3a013..883428a 100644 --- a/worldsrv/action_login.go +++ b/worldsrv/action_login.go @@ -250,6 +250,7 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf // 用缓存信息做登录,有account // 根据StartLogin代码,这里ls.acc一定不为nil + // 验证token ls = LoginStateMgrSington.GetLoginStateByName(UserKey(csl.GetUsername(), csl.GetPlatform(), tagkey)) if ls != nil { acc := ls.acc diff --git a/worldsrv/trascate_webapi.go b/worldsrv/trascate_webapi.go index d6ad713..8c2f456 100644 --- a/worldsrv/trascate_webapi.go +++ b/worldsrv/trascate_webapi.go @@ -3,6 +3,7 @@ package main import ( "crypto/md5" "encoding/hex" + "encoding/json" "errors" "fmt" "io" @@ -2876,6 +2877,33 @@ func init() { return common.ResponseTag_TransactYield, pack })) + WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/platform/createUser", WebAPIHandlerWrapper( + func(tNode *transact.TransNode, params []byte) (int, interface{}) { + pack := &webapi.PlatfromGameLoginRsp{ + Success: false, + Code: 200, + Message: "未知错误", + } + pack.Data.Url = "http://192.168.31.173/web-mobile-p102/" + + logger.Logger.Tracef("/api/platform/createUse %v", pack) + + var jsonDataRsp []byte + task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + //b, err = webapi.API_ExchangeRecord(common.GetAppId(), msg) + pack.Success = true + pack.Message = "返回成功" + return nil + }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { + + jsonDataRsp, _ = json.Marshal(pack) + + tNode.TransRep.RetFiels = jsonDataRsp + tNode.Resume() + }), "/api/platform/createUse").Start() + return common.ResponseTag_TransactYield, jsonDataRsp + })) + WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/game/exchange_order", WebAPIHandlerWrapper( func(tNode *transact.TransNode, params []byte) (int, interface{}) { pack := &webapiproto.SAGetExchangeOrder{ @@ -2979,41 +3007,6 @@ func init() { return common.ResponseTag_TransactYield, pack })) - WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/platform/createUse", WebAPIHandlerWrapper( - func(tNode *transact.TransNode, params []byte) (int, interface{}) { - pack := &webapiproto.SAGetExchangeOrder{ - Tag: webapiproto.TagCode_FAILED, - } - msg := &webapiproto.ASGetExchangeOrder{} - var err error - err = proto.Unmarshal(params, msg) - if err != nil { - pack.Tag = webapiproto.TagCode_FAILED - logger.Logger.Errorf("/api/game/exchange_order Unmarshal err: %v", err) - return common.ResponseTag_ParamError, pack - } - - logger.Logger.Tracef("/api/game/exchange_order %v", msg) - - var b []byte - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - b, err = webapi.API_ExchangeRecord(common.GetAppId(), msg) - return nil - }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { - if err != nil || b == nil { - logger.Logger.Errorf("/api/game/exchange_order API_ExchangeList err: %v", err) - pack.Tag = webapiproto.TagCode_FAILED - } else { - err = proto.Unmarshal(b, pack) - if err != nil { - logger.Logger.Errorf("/api/game/exchange_order Unmarshal err: %v", err) - } - } - tNode.TransRep.RetFiels = pack - tNode.Resume() - }), "/api/game/exchange_order").Start() - return common.ResponseTag_TransactYield, pack - })) } type playerDataParam struct {