From 95cbec95e0fef14fe51a6e6361e993eef0391379 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Thu, 23 Jul 2020 20:04:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8C=85=E5=90=8D=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=B4=A6=E5=8F=B7=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=89=93=E7=82=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/ConstDefine/AppConst.cs | 3 +- Assets/LuaFramework/Scripts/SDK/MessageDef.cs | 1 + Assets/LuaFramework/Scripts/SDK/SDKManager.cs | 19 +++++ .../~Lua/Modules/Bag/BagManager.lua | 10 ++- .../~Lua/Modules/Login/LoginManager.lua | 5 ++ .../~Lua/Modules/Login/LoginPanel.lua | 7 +- .../~Lua/Modules/Net/NetManager.lua | 9 +- .../~Lua/Modules/Pay/PayManager.lua | 2 + .../Source/Generate/GameLogic_AppConstWrap.cs | 30 +++++++ Assets/Source/Generate/SDK_SDKManagerWrap.cs | 85 +++++++++++++++++++ 10 files changed, 157 insertions(+), 14 deletions(-) diff --git a/Assets/LuaFramework/Scripts/ConstDefine/AppConst.cs b/Assets/LuaFramework/Scripts/ConstDefine/AppConst.cs index 228499d3d9..484c86d82b 100644 --- a/Assets/LuaFramework/Scripts/ConstDefine/AppConst.cs +++ b/Assets/LuaFramework/Scripts/ConstDefine/AppConst.cs @@ -171,7 +171,8 @@ namespace GameLogic public static string SdkId; //SDK UId public static string OpenId; //开天SDK UId public static string TokenStr; //开天SDK Token - public static string SdkChannel; //SDK UId + public static string SdkChannel; //SDK 渠道 + public static string SdkPackageName; //SDK包名 public static int Url_JoinRoomID = 0; diff --git a/Assets/LuaFramework/Scripts/SDK/MessageDef.cs b/Assets/LuaFramework/Scripts/SDK/MessageDef.cs index d3d7a6b00f..9df7679bf0 100644 --- a/Assets/LuaFramework/Scripts/SDK/MessageDef.cs +++ b/Assets/LuaFramework/Scripts/SDK/MessageDef.cs @@ -10,6 +10,7 @@ namespace SDK{ public const int MSG_PayCallback = 3; public const int MSG_SwitchAccountCallback = 4; public const int MSG_LogoutCallback = 5; + public const int MSG_RegisterCallback = 6; } } diff --git a/Assets/LuaFramework/Scripts/SDK/SDKManager.cs b/Assets/LuaFramework/Scripts/SDK/SDKManager.cs index 7e6dc106d9..d74171b810 100644 --- a/Assets/LuaFramework/Scripts/SDK/SDKManager.cs +++ b/Assets/LuaFramework/Scripts/SDK/SDKManager.cs @@ -19,6 +19,9 @@ namespace SDK public delegate void InitLaunchAction(string data); public InitLaunchAction onInitLaunchCallback; + public delegate void RegisterAction(string data); + public RegisterAction onRegisterCallback; + public delegate void LoginAction(string data); public LoginAction onLoginCallback; @@ -77,6 +80,12 @@ namespace SDK onInitLaunchCallback(msg.data); } break; + case MessageDef.MSG_RegisterCallback: + if (null != onLoginCallback) + { + onRegisterCallback(msg.data); + } + break; case MessageDef.MSG_LoginCallback: if (null != onLoginCallback) { @@ -165,6 +174,16 @@ namespace SDK data = data }); } + //sdk 注册 回调 + public void RegisterCallback(string data) + { + Debug.Log("Helper : RegisterCallback - data: " + data); + proxy.PushMessage(new Message + { + msgId = MessageDef.MSG_RegisterCallback, + data = data + }); + } //sdk login 回调 public void LoginCallback(string data) { diff --git a/Assets/ManagedResources/~Lua/Modules/Bag/BagManager.lua b/Assets/ManagedResources/~Lua/Modules/Bag/BagManager.lua index 1aa62a0585..b512bb1418 100644 --- a/Assets/ManagedResources/~Lua/Modules/Bag/BagManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Bag/BagManager.lua @@ -64,10 +64,12 @@ function this.UpdateBagData(_itemData, isNoSendNewItemEvent) end -- 货币数据 - ThinkingAnalyticsManager.SetSuperProperties({ - coins_amount = BagManager.GetItemCountById(14), - diamond_amount = BagManager.GetItemCountById(16), - }) + if itemdata.itemId == 14 or itemdata.itemId == 16 then + ThinkingAnalyticsManager.SetSuperProperties({ + coins_amount = BagManager.GetItemCountById(14), + diamond_amount = BagManager.GetItemCountById(16), + }) + end end diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua index 4d3f862ba0..c182e45ee2 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua @@ -21,6 +21,11 @@ function this.Initialize() this.CurAccount=PlayerPrefs.GetString(this.GameName.."Account",'') this.CurSession=PlayerPrefs.GetString(this.GameName.."Session",'') + SDKMgr.onRegisterCallback = function(loginResp) + -- Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLoginSuccess,loginResp) + ThinkingAnalyticsManager.Track("create_account") + end + SDKMgr.onLoginCallback = function(loginResp) Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLoginSuccess,loginResp) -- ThinkingAnalyticsManager.Track("app_login") diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua index a78114f909..505a78cca8 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua @@ -237,6 +237,7 @@ function this.RefreshLoginStatus(loginResp) AppConst.OpenId = result[2] AppConst.TokenStr = result[4] AppConst.SdkChannel = result[5] + AppConst.SdkPackageName = AndroidDeviceInfo.Instance:GetPackageName() -- this.SetSDKExtensionParams(result[4]) Log(string.format("%sjl_loginserver/getServerList?openId=%s&channel=%s&plat=android&sub_channel=%s", LoginRoot_Url, AppConst.OpenId, LoginRoot_Channel, LoginRoot_SubChannel)) networkMgr:SendGetHttp(string.format("%sjl_loginserver/getServerList?openId=%s&channel=%s&plat=android&sub_channel=%s", LoginRoot_Url, AppConst.OpenId, LoginRoot_Channel, LoginRoot_SubChannel), @@ -388,7 +389,7 @@ function this.OnReceiveLogin(str) AppConst.UserId = data.uid AppConst.Token = data.token local openId = AppConst.isSDKLogin and AppConst.OpenId or PlayerPrefs.GetString(openIdkey) - NetManager.LoginRequest(openId, LoginManager.pt_pId, LoginManager.pt_gId, function() + NetManager.LoginRequest(openId, function() if not LoginManager.IsLogin then LoginManager.IsLogin = true this.ExecuteLoading() @@ -516,7 +517,7 @@ function this.OnConnect(network) .. "&platform=" .. 1 .. "&sub_channel=" .. LoginRoot_SubChannel .. "&pid=" .. AppConst.SdkChannel --LoginManager.pt_pId - .. "&gid=" .. "" --LoginManager.pt_gId + .. "&gid=" .. AppConst.SdkPayChannel --LoginManager.pt_gId .. "&version=" .. LoginRoot_PackageVersion) networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getUserInfo?openId=" .. AppConst.OpenId @@ -525,7 +526,7 @@ function this.OnConnect(network) .. "&platform=" .. 1 .. "&sub_channel=" .. LoginRoot_SubChannel .. "&pid=" .. AppConst.SdkChannel --LoginManager.pt_pId - .. "&gid=" .. "" --LoginManager.pt_gId + .. "&gid=" .. AppConst.SdkPayChannel --LoginManager.pt_gId .. "&version=" .. LoginRoot_PackageVersion, this.OnReceiveLogin, nil, nil, nil) else diff --git a/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua b/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua index 59879d2425..54d8712209 100644 --- a/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua @@ -30,7 +30,7 @@ function this.IsConnect() end --请求登录 -function this.LoginRequest(openId, pt_pid, pt_gid, func) +function this.LoginRequest(openId, func) local data = PlayerInfoProto_pb.LoginRequest() data.device_id_s = AppConst.isSDK and AndroidDeviceInfo.Instance:GetDeviceID() or "" data.idfa_sOr_imei_s = AppConst.isSDK and AndroidDeviceInfo.Instance:GetIMEICode() or "" @@ -43,7 +43,7 @@ function this.LoginRequest(openId, pt_pid, pt_gid, func) data.ip_s = AppConst.isSDK and AndroidDeviceInfo.Instance:GetLocalIpAddress() or "" data.distinct_id = AppConst.isSDK and openId or "" data.openId = openId - data.channel_s = pt_pid.."#"..pt_gid + data.channel_s = AppConst.isSDK and AppConst.SdkChannel .. "#" .. AppConst.SdkPackageName or "" --pt_pid.."#"..pt_gid data.platform_s = AppConst.isSDK and "ADR" or "PC" local msg = data:SerializeToString() @@ -63,15 +63,12 @@ function this.LoginRequest(openId, pt_pid, pt_gid, func) end end AppConst.Token = msg.newToken - - Log("get package name : "..AndroidDeviceInfo.Instance:GetPackageName()) - -- 打点 ThinkingAnalyticsManager.SetDistinctId(AppConst.OpenId) ThinkingAnalyticsManager.SetSuperProperties({ server_id = LoginManager.ServerId, account = AppConst.OpenId, - ["Bundle-id"] = AndroidDeviceInfo.Instance:GetPackageName(), + ["Bundle-id"] = AppConst.SdkPackageName, xx_id = AppConst.SdkChannel }) TapDBManager.SetUser(openId) diff --git a/Assets/ManagedResources/~Lua/Modules/Pay/PayManager.lua b/Assets/ManagedResources/~Lua/Modules/Pay/PayManager.lua index e20614abf8..96c7a37c3c 100644 --- a/Assets/ManagedResources/~Lua/Modules/Pay/PayManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Pay/PayManager.lua @@ -87,7 +87,9 @@ function this.RequestPay(context) -- ThinkingAnalyticsManager.Track("create_order", { goods_id = context.Id, + goods_name = context.Name, order_money_amount = context.Price, + ["Bundle-id"] = AppConst.SdkPackageName, }) end diff --git a/Assets/Source/Generate/GameLogic_AppConstWrap.cs b/Assets/Source/Generate/GameLogic_AppConstWrap.cs index fa964753b5..d5ab3b1b16 100644 --- a/Assets/Source/Generate/GameLogic_AppConstWrap.cs +++ b/Assets/Source/Generate/GameLogic_AppConstWrap.cs @@ -58,6 +58,7 @@ public class GameLogic_AppConstWrap L.RegVar("OpenId", get_OpenId, set_OpenId); L.RegVar("TokenStr", get_TokenStr, set_TokenStr); L.RegVar("SdkChannel", get_SdkChannel, set_SdkChannel); + L.RegVar("SdkPackageName", get_SdkPackageName, set_SdkPackageName); L.RegVar("Url_JoinRoomID", get_Url_JoinRoomID, set_Url_JoinRoomID); L.RegConstant("AppID", 129213); L.RegVar("AppKey", get_AppKey, null); @@ -798,6 +799,20 @@ public class GameLogic_AppConstWrap } } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int get_SdkPackageName(IntPtr L) + { + try + { + LuaDLL.lua_pushstring(L, GameLogic.AppConst.SdkPackageName); + return 1; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_Url_JoinRoomID(IntPtr L) { @@ -1837,6 +1852,21 @@ public class GameLogic_AppConstWrap } } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int set_SdkPackageName(IntPtr L) + { + try + { + string arg0 = ToLua.CheckString(L, 2); + GameLogic.AppConst.SdkPackageName = arg0; + return 0; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_Url_JoinRoomID(IntPtr L) { diff --git a/Assets/Source/Generate/SDK_SDKManagerWrap.cs b/Assets/Source/Generate/SDK_SDKManagerWrap.cs index 554db6ca1b..30f8d3fd3d 100644 --- a/Assets/Source/Generate/SDK_SDKManagerWrap.cs +++ b/Assets/Source/Generate/SDK_SDKManagerWrap.cs @@ -17,6 +17,7 @@ public class SDK_SDKManagerWrap L.RegFunction("GetPayOrderID", GetPayOrderID); L.RegFunction("CaptureShot", CaptureShot); L.RegFunction("InitCallback", InitCallback); + L.RegFunction("RegisterCallback", RegisterCallback); L.RegFunction("LoginCallback", LoginCallback); L.RegFunction("PayCallback", PayCallback); L.RegFunction("SwitchAccountCallback", SwitchAccountCallback); @@ -24,6 +25,7 @@ public class SDK_SDKManagerWrap L.RegFunction("__eq", op_Equality); L.RegFunction("__tostring", ToLua.op_ToString); L.RegVar("onInitLaunchCallback", get_onInitLaunchCallback, set_onInitLaunchCallback); + L.RegVar("onRegisterCallback", get_onRegisterCallback, set_onRegisterCallback); L.RegVar("onLoginCallback", get_onLoginCallback, set_onLoginCallback); L.RegVar("onPayCallback", get_onPayCallback, set_onPayCallback); L.RegVar("onSwitchAccountCallback", get_onSwitchAccountCallback, set_onSwitchAccountCallback); @@ -33,6 +35,7 @@ public class SDK_SDKManagerWrap L.RegFunction("SwitchAccountAction", SDK_SDKManager_SwitchAccountAction); L.RegFunction("PayAction", SDK_SDKManager_PayAction); L.RegFunction("LoginAction", SDK_SDKManager_LoginAction); + L.RegFunction("RegisterAction", SDK_SDKManager_RegisterAction); L.RegFunction("InitLaunchAction", SDK_SDKManager_InitLaunchAction); L.EndClass(); } @@ -202,6 +205,23 @@ public class SDK_SDKManagerWrap } } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int RegisterCallback(IntPtr L) + { + try + { + ToLua.CheckArgsCount(L, 2); + SDK.SDKManager obj = (SDK.SDKManager)ToLua.CheckObject(L, 1); + string arg0 = ToLua.CheckString(L, 2); + obj.RegisterCallback(arg0); + return 0; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int LoginCallback(IntPtr L) { @@ -307,6 +327,25 @@ public class SDK_SDKManagerWrap } } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int get_onRegisterCallback(IntPtr L) + { + object o = null; + + try + { + o = ToLua.ToObject(L, 1); + SDK.SDKManager obj = (SDK.SDKManager)o; + SDK.SDKManager.RegisterAction ret = obj.onRegisterCallback; + ToLua.Push(L, ret); + return 1; + } + catch(Exception e) + { + return LuaDLL.toluaL_exception(L, e, o, "attempt to index onRegisterCallback on a nil value"); + } + } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_onLoginCallback(IntPtr L) { @@ -421,6 +460,25 @@ public class SDK_SDKManagerWrap } } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int set_onRegisterCallback(IntPtr L) + { + object o = null; + + try + { + o = ToLua.ToObject(L, 1); + SDK.SDKManager obj = (SDK.SDKManager)o; + SDK.SDKManager.RegisterAction arg0 = (SDK.SDKManager.RegisterAction)ToLua.CheckDelegate(L, 2); + obj.onRegisterCallback = arg0; + return 0; + } + catch(Exception e) + { + return LuaDLL.toluaL_exception(L, e, o, "attempt to index onRegisterCallback on a nil value"); + } + } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int set_onLoginCallback(IntPtr L) { @@ -605,6 +663,33 @@ public class SDK_SDKManagerWrap } } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int SDK_SDKManager_RegisterAction(IntPtr L) + { + try + { + int count = LuaDLL.lua_gettop(L); + LuaFunction func = ToLua.CheckLuaFunction(L, 1); + + if (count == 1) + { + Delegate arg1 = DelegateTraits.Create(func); + ToLua.Push(L, arg1); + } + else + { + LuaTable self = ToLua.CheckLuaTable(L, 2); + Delegate arg1 = DelegateTraits.Create(func, self); + ToLua.Push(L, arg1); + } + return 1; + } + catch(Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int SDK_SDKManager_InitLaunchAction(IntPtr L) {