com.taptap.sdk.core 4.8.0-beta.1 → 4.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Mobile/Editor/NativeDependencies.xml +3 -3
- package/Mobile/Runtime/AndroidNativeWrapper.cs +2 -1
- package/Mobile/Runtime/BridgeAndroid.cs +2 -1
- package/Mobile/Runtime/BridgeIOS.cs +2 -3
- package/Mobile/Runtime/EngineBridgeInitializer.cs +2 -1
- package/Mobile/Runtime/TapCoreMobile.cs +6 -5
- package/Mobile/Runtime/TapEventMobile.cs +22 -21
- package/Resources/TapMessage.prefab +8 -8
- package/Runtime/Internal/Http/TapHttpClient.cs +2 -1
- package/Runtime/Internal/Http/TapHttpUtils.cs +3 -2
- package/Runtime/Internal/Log/TapLog.cs +39 -3
- package/Runtime/Internal/Platform/PlatformTypeUtils.cs +3 -7
- package/Runtime/Internal/UI/Base/UIManager.cs +2 -1
- package/Runtime/Internal/UI/BasePanel/BasePanelController.cs +2 -1
- package/Runtime/Internal/Utils/BridgeUtils.cs +23 -22
- package/Runtime/Internal/Utils/EventManager.cs +1 -1
- package/Runtime/Internal/Utils/ImageUtils.cs +5 -4
- package/Runtime/Public/DataStorage.cs +17 -4
- package/Runtime/Public/Log/TapLogger.cs +1 -1
- package/Runtime/Public/TapTapEvent.cs +2 -1
- package/Runtime/Public/TapTapSDK.cs +1 -1
- package/Standalone/Plugins/macOS/libtapsdkcorecpp.dylib.meta +1 -1
- package/Standalone/Plugins/x86/tapsdkcore.dll +0 -0
- package/Standalone/Plugins/x86_64/tapsdkcore.dll +0 -0
- package/Standalone/Plugins/x86_64/taptap_api.dll +0 -0
- package/Standalone/Plugins/x86_64/taptap_api.dll.meta +34 -6
- package/Standalone/Runtime/Internal/Bean/TapGatekeeper.cs +0 -2
- package/Standalone/Runtime/Internal/DeviceInfo.cs +2 -1
- package/Standalone/Runtime/Internal/EventSender.cs +2 -2
- package/Standalone/Runtime/Internal/Http/TapHttpUtils.cs +0 -8
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogWrapper.cs +2 -2
- package/Standalone/Runtime/Internal/Prefs.cs +3 -2
- package/Standalone/Runtime/Internal/TapClientBridge.cs +222 -139
- package/Standalone/Runtime/Internal/TapClientBridgePoll.cs +2 -1
- package/Standalone/Runtime/Internal/Tracker.cs +11 -10
- package/Standalone/Runtime/Internal/UI/TapClientConnectTipController.cs +6 -6
- package/Standalone/Runtime/Internal/User.cs +2 -3
- package/Standalone/Runtime/Public/TapClientStandalone.cs +122 -84
- package/Standalone/Runtime/Public/TapCoreStandalone.cs +1 -15
- package/Standalone/Runtime/Public/TapEventStandalone.cs +9 -9
- package/link.xml.meta +1 -1
- package/package.json +9 -9
|
@@ -7,6 +7,7 @@ using System;
|
|
|
7
7
|
using System.Runtime.InteropServices;
|
|
8
8
|
using TapSDK.Core.Standalone.Internal.Openlog;
|
|
9
9
|
using System.Threading;
|
|
10
|
+
using TapSDK.Core.Internal.Log;
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
|
|
@@ -36,13 +37,13 @@ namespace TapSDK.Core.Standalone
|
|
|
36
37
|
if (isRuningIsLaunchedFromTapTapPC)
|
|
37
38
|
{
|
|
38
39
|
UIManager.Instance.OpenToast("IsLaunchedFromTapTapPC 正在执行,请勿重复调用", UIManager.GeneralToastLevel.Error);
|
|
39
|
-
|
|
40
|
+
TapLog.Error("IsLaunchedFromTapTapPC 正在执行,请勿重复调用");
|
|
40
41
|
return false;
|
|
41
42
|
}
|
|
42
43
|
// 多次执行时返回上一次结果
|
|
43
44
|
if (lastIsLaunchedFromTapTapPCResult != -1)
|
|
44
45
|
{
|
|
45
|
-
|
|
46
|
+
TapLog.Log("IsLaunchedFromTapTapPC duplicate invoke return " + lastIsLaunchedFromTapTapPCResult);
|
|
46
47
|
return lastIsLaunchedFromTapTapPCResult > 0;
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -51,7 +52,7 @@ namespace TapSDK.Core.Standalone
|
|
|
51
52
|
if (coreOptions == null)
|
|
52
53
|
{
|
|
53
54
|
UIManager.Instance.OpenToast("IsLaunchedFromTapTapPC 调用必须在初始化之后", UIManager.GeneralToastLevel.Error);
|
|
54
|
-
|
|
55
|
+
TapLog.Error("IsLaunchedFromTapTapPC 调用必须在初始化之后");
|
|
55
56
|
return false;
|
|
56
57
|
}
|
|
57
58
|
string clientId = coreOptions.clientId;
|
|
@@ -59,7 +60,7 @@ namespace TapSDK.Core.Standalone
|
|
|
59
60
|
if (string.IsNullOrEmpty(clientId) || string.IsNullOrEmpty(pubKey))
|
|
60
61
|
{
|
|
61
62
|
UIManager.Instance.OpenToast("clientId 及 TapPubKey 参数都不能为空, clientId =" + clientId + ", TapPubKey = " + pubKey, UIManager.GeneralToastLevel.Error);
|
|
62
|
-
|
|
63
|
+
TapLog.Error("clientId 或 TapPubKey 无效, clientId = " + clientId + ", TapPubKey = " + pubKey);
|
|
63
64
|
return false;
|
|
64
65
|
}
|
|
65
66
|
isRuningIsLaunchedFromTapTapPC = true;
|
|
@@ -68,27 +69,28 @@ namespace TapSDK.Core.Standalone
|
|
|
68
69
|
TapCoreTracker.Instance.TrackStart(TapCoreTracker.METHOD_LAUNCHER, sessionId);
|
|
69
70
|
try
|
|
70
71
|
{
|
|
71
|
-
TapInitResult result = await
|
|
72
|
+
TapInitResult result = await RunClientBridgeMethod(clientId, pubKey);
|
|
73
|
+
TapLog.Log("check startupWithClientBridge finished thread = " + Thread.CurrentThread.ManagedThreadId);
|
|
72
74
|
isRuningIsLaunchedFromTapTapPC = false;
|
|
73
75
|
if (result.needQuitGame)
|
|
74
76
|
{
|
|
75
77
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
76
78
|
TapCoreTracker.Instance.TrackSuccess(TapCoreTracker.METHOD_LAUNCHER, sessionId, TapCoreTracker.SUCCESS_TYPE_RESTART);
|
|
77
|
-
|
|
79
|
+
TapLog.Log("IsLaunchedFromTapTapPC Quit game");
|
|
78
80
|
Application.Quit();
|
|
79
81
|
return false;
|
|
80
82
|
}
|
|
81
83
|
else
|
|
82
84
|
{
|
|
83
|
-
if (result.result == TapSDKInitResult.OK)
|
|
85
|
+
if (result.result == (int)TapSDKInitResult.OK)
|
|
84
86
|
{
|
|
85
87
|
string currentClientId;
|
|
86
88
|
bool isFetchClientIdSuccess = TapClientBridge.GetClientId(out currentClientId);
|
|
87
|
-
|
|
89
|
+
TapLog.Log("IsLaunchedFromTapTapPC get clientId = " + currentClientId);
|
|
88
90
|
if (isFetchClientIdSuccess && !string.IsNullOrEmpty(currentClientId) && currentClientId != clientId)
|
|
89
91
|
{
|
|
90
92
|
UIManager.Instance.OpenToast("SDK 中配置的 clientId = " + clientId + "与 Tap 启动器中" + currentClientId + "不一致", UIManager.GeneralToastLevel.Error);
|
|
91
|
-
|
|
93
|
+
TapLog.Error("SDK 中配置的 clientId = " + clientId + "与 Tap 启动器中" + currentClientId + "不一致");
|
|
92
94
|
TapCoreTracker.Instance.TrackFailure(TapCoreTracker.METHOD_LAUNCHER, sessionId, -1, "SDK 中配置的 clientId = " + clientId + "与 Tap 启动器中" + currentClientId + "不一致");
|
|
93
95
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
94
96
|
return false;
|
|
@@ -97,17 +99,17 @@ namespace TapSDK.Core.Standalone
|
|
|
97
99
|
bool fetchOpenIdSuccess = TapClientBridge.GetTapUserOpenId(out openId);
|
|
98
100
|
if (fetchOpenIdSuccess)
|
|
99
101
|
{
|
|
100
|
-
|
|
102
|
+
TapLog.Log("IsLaunchedFromTapTapPC get openId = " + openId);
|
|
101
103
|
EventManager.TriggerEvent(EventManager.IsLaunchedFromTapTapPCFinished, openId);
|
|
102
104
|
}
|
|
103
105
|
else
|
|
104
106
|
{
|
|
105
|
-
|
|
107
|
+
TapLog.Log("IsLaunchedFromTapTapPC get openId failed");
|
|
106
108
|
}
|
|
107
109
|
lastIsLaunchedFromTapTapPCResult = 1;
|
|
108
110
|
TapClientBridgePoll.StartUp();
|
|
109
111
|
TapCoreTracker.Instance.TrackSuccess(TapCoreTracker.METHOD_LAUNCHER, sessionId, TapCoreTracker.SUCCESS_TYPE_INIT);
|
|
110
|
-
|
|
112
|
+
TapLog.Log("IsLaunchedFromTapTapPC check success");
|
|
111
113
|
return true;
|
|
112
114
|
}
|
|
113
115
|
else
|
|
@@ -115,7 +117,7 @@ namespace TapSDK.Core.Standalone
|
|
|
115
117
|
|
|
116
118
|
TapCoreTracker.Instance.TrackFailure(TapCoreTracker.METHOD_LAUNCHER, sessionId, (int)result.result, result.errorMsg ?? "");
|
|
117
119
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
118
|
-
|
|
120
|
+
TapLog.Log("IsLaunchedFromTapTapPC show TapClient tip Pannel " + result.result + " , error = " + result.errorMsg);
|
|
119
121
|
string tipPannelPath = "Prefabs/TapClient/TapClientConnectTipPanel";
|
|
120
122
|
if (Resources.Load<GameObject>(tipPannelPath) != null)
|
|
121
123
|
{
|
|
@@ -126,46 +128,33 @@ namespace TapSDK.Core.Standalone
|
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
|
-
catch (TimeoutException e)
|
|
130
|
-
{
|
|
131
|
-
lastIsLaunchedFromTapTapPCResult = 0;
|
|
132
|
-
TapCoreTracker.Instance.TrackFailure(TapCoreTracker.METHOD_LAUNCHER, sessionId, (int)TapSDKInitResult.Timeout, e.Message ?? "");
|
|
133
|
-
|
|
134
|
-
TapLogger.Debug("IsLaunchedFromTapTapPC check timeout");
|
|
135
|
-
string tipPannelPath = "Prefabs/TapClient/TapClientConnectTipPanel";
|
|
136
|
-
if (Resources.Load<GameObject>(tipPannelPath) != null)
|
|
137
|
-
{
|
|
138
|
-
var pannel = UIManager.Instance.OpenUI<TapClientConnectTipController>(tipPannelPath);
|
|
139
|
-
pannel.Show(TapSDKInitResult.Timeout);
|
|
140
|
-
}
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
131
|
catch (Exception e)
|
|
144
132
|
{
|
|
145
133
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
146
134
|
TapCoreTracker.Instance.TrackFailure(TapCoreTracker.METHOD_LAUNCHER, sessionId, (int)TapSDKInitResult.Unknown, e.Message ?? "");
|
|
147
135
|
|
|
148
|
-
|
|
136
|
+
TapLog.Log("IsLaunchedFromTapTapPC check exception = " + e.Message + " \n" + e.StackTrace);
|
|
149
137
|
string tipPannelPath = "Prefabs/TapClient/TapClientConnectTipPanel";
|
|
150
138
|
if (Resources.Load<GameObject>(tipPannelPath) != null)
|
|
151
139
|
{
|
|
152
140
|
var pannel = UIManager.Instance.OpenUI<TapClientConnectTipController>(tipPannelPath);
|
|
153
|
-
pannel.Show(TapSDKInitResult.Unknown);
|
|
141
|
+
pannel.Show((int)TapSDKInitResult.Unknown);
|
|
154
142
|
}
|
|
155
143
|
return false;
|
|
156
144
|
}
|
|
157
145
|
}
|
|
158
146
|
|
|
159
|
-
private static async Task<TapInitResult>
|
|
147
|
+
private static async Task<TapInitResult> RunClientBridgeMethod(string clientId, string pubKey)
|
|
160
148
|
{
|
|
161
149
|
TaskCompletionSource<TapInitResult> task = new TaskCompletionSource<TapInitResult>();
|
|
162
150
|
try
|
|
163
151
|
{
|
|
164
|
-
|
|
152
|
+
await Task.Run(() =>
|
|
165
153
|
{
|
|
154
|
+
TapLog.Log( "check startupWithClientBridge start thread = " + Thread.CurrentThread.ManagedThreadId);
|
|
166
155
|
bool needQuitGame = TapClientBridge.TapSDK_RestartAppIfNecessary(clientId);
|
|
167
|
-
|
|
168
|
-
|
|
156
|
+
TapLog.Log("RunClientBridgeMethodWithTimeout invoke TapSDK_RestartAppIfNecessary result = " + needQuitGame);
|
|
157
|
+
TapLog.Log("RunClientBridgeMethodWithTimeout invoke TapSDK_RestartAppIfNecessary finished " );
|
|
169
158
|
if (needQuitGame)
|
|
170
159
|
{
|
|
171
160
|
tapInitResult = new TapInitResult(needQuitGame);
|
|
@@ -173,53 +162,22 @@ namespace TapSDK.Core.Standalone
|
|
|
173
162
|
else
|
|
174
163
|
{
|
|
175
164
|
string outputError;
|
|
176
|
-
|
|
177
|
-
|
|
165
|
+
int tapSDKInitResult = TapClientBridge.CheckInitState(out outputError, pubKey);
|
|
166
|
+
TapLog.Log("RunClientBridgeMethodWithTimeout invoke CheckInitState result = " + tapSDKInitResult + ", error = " + outputError);
|
|
178
167
|
tapInitResult = new TapInitResult(tapSDKInitResult, outputError);
|
|
179
168
|
}
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
task.TrySetResult(tapInitResult);
|
|
169
|
+
task.TrySetResult(tapInitResult);
|
|
170
|
+
});
|
|
183
171
|
|
|
184
172
|
}
|
|
185
|
-
catch (TimeoutException ex)
|
|
186
|
-
{
|
|
187
|
-
TapLogger.Debug("RunClientBridgeMethodWithTimeout invoke CheckInitState 方法执行超时!");
|
|
188
|
-
task.TrySetException(ex);
|
|
189
|
-
}
|
|
190
173
|
catch (Exception ex)
|
|
191
174
|
{
|
|
192
|
-
|
|
175
|
+
TapLog.Log("RunClientBridgeMethodWithTimeout invoke C 方法出错!" + ex.Message);
|
|
193
176
|
task.TrySetException(ex);
|
|
194
177
|
}
|
|
195
178
|
return await task.Task;
|
|
196
179
|
}
|
|
197
180
|
|
|
198
|
-
/// <summary>
|
|
199
|
-
/// 在 IO 线程执行 C 方法,超时 5 秒后切回主线程
|
|
200
|
-
/// </summary>
|
|
201
|
-
private static async Task<T> ExecuteWithTimeoutAsync<T>(Func<T> cMethod, TimeSpan timeout)
|
|
202
|
-
{
|
|
203
|
-
using (var cts = new CancellationTokenSource())
|
|
204
|
-
{
|
|
205
|
-
Task<T> ioTask = Task.Run(cMethod); // 在后台线程执行 C 方法
|
|
206
|
-
Task delayTask = Task.Delay(timeout); // 超时任务
|
|
207
|
-
|
|
208
|
-
Task completedTask = await Task.WhenAny(ioTask, delayTask);
|
|
209
|
-
|
|
210
|
-
if (completedTask == delayTask)
|
|
211
|
-
{
|
|
212
|
-
cts.Cancel(); // 取消 C 方法任务
|
|
213
|
-
throw new TimeoutException("C 方法执行超时!");
|
|
214
|
-
}
|
|
215
|
-
else
|
|
216
|
-
{
|
|
217
|
-
cts.Cancel();
|
|
218
|
-
return await ioTask;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
181
|
/// <summary>
|
|
224
182
|
/// 是否需要从启动器登录
|
|
225
183
|
/// </summary>
|
|
@@ -228,6 +186,10 @@ namespace TapSDK.Core.Standalone
|
|
|
228
186
|
return isChannelPackage;
|
|
229
187
|
}
|
|
230
188
|
|
|
189
|
+
public static bool isPassedInLaunchedFromTapTapPCCheck(){
|
|
190
|
+
return lastIsLaunchedFromTapTapPCResult > 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
231
193
|
|
|
232
194
|
private static Action<bool, string> currentLoginCallback;
|
|
233
195
|
|
|
@@ -240,19 +202,19 @@ namespace TapSDK.Core.Standalone
|
|
|
240
202
|
if (lastIsLaunchedFromTapTapPCResult == -1)
|
|
241
203
|
{
|
|
242
204
|
// UIManager.Instance.OpenToast("IsLaunchedFromTapTapPC 正在执行,请在完成后调用授权接口", UIManager.GeneralToastLevel.Error);
|
|
243
|
-
|
|
205
|
+
TapLog.Error(" login must be invoked after IsLaunchedFromTapTapPC success");
|
|
244
206
|
throw new Exception("login must be invoked after IsLaunchedFromTapTapPC success");
|
|
245
207
|
}
|
|
246
|
-
|
|
208
|
+
TapLog.Log("LoginWithScopes start login by tapclient thread = " + Thread.CurrentThread.ManagedThreadId);
|
|
247
209
|
try
|
|
248
210
|
{
|
|
249
|
-
TapClientBridge.RegisterCallback(TapEventID.
|
|
250
|
-
AuthorizeResult authorizeResult = TapClientBridge.
|
|
211
|
+
TapClientBridge.RegisterCallback(TapEventID.AuthorizeFinished_internal, loginCallbackDelegate);
|
|
212
|
+
AuthorizeResult authorizeResult = TapClientBridge.LoginWithScopesInternal(scopes, responseType, redirectUri,
|
|
251
213
|
codeChallenge, state, codeChallengeMethod, versonCode, sdkUa, info);
|
|
252
|
-
|
|
214
|
+
TapLog.Log("LoginWithScopes start result = " + authorizeResult);
|
|
253
215
|
if (authorizeResult != AuthorizeResult.OK)
|
|
254
216
|
{
|
|
255
|
-
TapClientBridge.UnRegisterCallback(TapEventID.
|
|
217
|
+
TapClientBridge.UnRegisterCallback(TapEventID.AuthorizeFinished_internal,loginCallbackDelegate);
|
|
256
218
|
return false;
|
|
257
219
|
}
|
|
258
220
|
else
|
|
@@ -264,8 +226,8 @@ namespace TapSDK.Core.Standalone
|
|
|
264
226
|
}
|
|
265
227
|
catch (Exception ex)
|
|
266
228
|
{
|
|
267
|
-
|
|
268
|
-
TapClientBridge.UnRegisterCallback(TapEventID.
|
|
229
|
+
TapLog.Log("LoginWithScopes start login by tapclient error = " + ex.Message);
|
|
230
|
+
TapClientBridge.UnRegisterCallback(TapEventID.AuthorizeFinished_internal,loginCallbackDelegate);
|
|
269
231
|
return false;
|
|
270
232
|
}
|
|
271
233
|
|
|
@@ -275,30 +237,106 @@ namespace TapSDK.Core.Standalone
|
|
|
275
237
|
[AOT.MonoPInvokeCallback(typeof(TapClientBridge.CallbackDelegate))]
|
|
276
238
|
static void loginCallbackDelegate(int id, IntPtr userData)
|
|
277
239
|
{
|
|
278
|
-
|
|
279
|
-
if (id == (int)TapEventID.
|
|
240
|
+
TapLog.Log("LoginWithScopes recevie callback " + id);
|
|
241
|
+
if (id == (int)TapEventID.AuthorizeFinished_internal)
|
|
280
242
|
{
|
|
281
|
-
|
|
243
|
+
TapLog.Log("LoginWithScopes callback thread = " + Thread.CurrentThread.ManagedThreadId);
|
|
282
244
|
TapClientBridge.AuthorizeFinishedResponse response = Marshal.PtrToStructure<TapClientBridge.AuthorizeFinishedResponse>(userData);
|
|
283
|
-
|
|
245
|
+
TapLog.Log("LoginWithScopes callback = " + response.is_cancel + " uri = " + response.callback_uri);
|
|
284
246
|
if (currentLoginCallback != null)
|
|
285
247
|
{
|
|
286
248
|
currentLoginCallback(response.is_cancel != 0, response.callback_uri);
|
|
287
|
-
TapClientBridge.UnRegisterCallback(TapEventID.
|
|
249
|
+
TapClientBridge.UnRegisterCallback(TapEventID.AuthorizeFinished_internal,loginCallbackDelegate);
|
|
288
250
|
currentLoginCallback = null;
|
|
289
251
|
}
|
|
290
252
|
}
|
|
291
253
|
}
|
|
254
|
+
|
|
255
|
+
// DLC 相关功能
|
|
256
|
+
private static Action<string, bool> currentDlcDelegate;
|
|
257
|
+
private static Action<bool> currentLicenseDelegate;
|
|
258
|
+
|
|
259
|
+
/// 查询是否购买 DLC , 未调用 isLaunchFromPC 会抛异常
|
|
260
|
+
public static bool QueryDLC(string skuId)
|
|
261
|
+
{
|
|
262
|
+
if (lastIsLaunchedFromTapTapPCResult != 1)
|
|
263
|
+
{
|
|
264
|
+
throw new Exception("queryDLC must be invoked after IsLaunchedFromTapTapPC success");
|
|
265
|
+
}
|
|
266
|
+
bool success = TapClientBridge.QueryDLC(skuId);
|
|
267
|
+
return success;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/// 跳转到 TapTap 客户端 DLC 购买页面 , 未调用 isLaunchFromPC 会抛异常
|
|
271
|
+
public static bool ShowStore(string skuId)
|
|
272
|
+
{
|
|
273
|
+
if (lastIsLaunchedFromTapTapPCResult != 1)
|
|
274
|
+
{
|
|
275
|
+
throw new Exception("purchaseDLC must be invoked after IsLaunchedFromTapTapPC success");
|
|
276
|
+
}
|
|
277
|
+
TapLog.Log("purchaseDLC start = " + skuId);
|
|
278
|
+
return TapClientBridge.TapDLC_ShowStore(skuId);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/// 注册 DLC 购买状态变更回调,包括购买成功和退款
|
|
282
|
+
public static void RegisterDLCOwnedCallback(Action<string, bool> dlcDelegate)
|
|
283
|
+
{
|
|
284
|
+
currentDlcDelegate = dlcDelegate;
|
|
285
|
+
TapClientBridge.RegisterCallback(TapEventID.DLCPlayableStatusChanged, DLCCallbackDelegate);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/// DLC 回调
|
|
289
|
+
[AOT.MonoPInvokeCallback(typeof(TapClientBridge.CallbackDelegate))]
|
|
290
|
+
static void DLCCallbackDelegate(int id, IntPtr userData)
|
|
291
|
+
{
|
|
292
|
+
TapLog.Log("queryDlC recevie callback " + id);
|
|
293
|
+
if (currentDlcDelegate != null)
|
|
294
|
+
{
|
|
295
|
+
TapClientBridge.DLCPlayableStatusChangedResponse response = Marshal.PtrToStructure<TapClientBridge.DLCPlayableStatusChangedResponse>(userData);
|
|
296
|
+
TapLog.Log("queryDlC callback = " + response.dlc_id + " isOwn = " + response.is_playable);
|
|
297
|
+
currentDlcDelegate(response.dlc_id, response.is_playable != 0);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/// 注册 License 购买状态变更回调,包括购买成功和退款
|
|
302
|
+
public static void RegisterLicenseCallback(Action<bool> licensecDelegate)
|
|
303
|
+
{
|
|
304
|
+
currentLicenseDelegate = licensecDelegate;
|
|
305
|
+
TapClientBridge.RegisterCallback(TapEventID.GamePlayableStatusChanged, LicenseCallbackDelegate);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/// License 回调
|
|
309
|
+
[AOT.MonoPInvokeCallback(typeof(TapClientBridge.CallbackDelegate))]
|
|
310
|
+
static void LicenseCallbackDelegate(int id, IntPtr userData)
|
|
311
|
+
{
|
|
312
|
+
TapLog.Log("License recevie callback " + id);
|
|
313
|
+
if (currentLicenseDelegate != null)
|
|
314
|
+
{
|
|
315
|
+
TapClientBridge.GamePlayableStatusChangedResponse response = Marshal.PtrToStructure<TapClientBridge.GamePlayableStatusChangedResponse>(userData);
|
|
316
|
+
TapLog.Log("License callback isOwn changed " + response.is_playable );
|
|
317
|
+
currentLicenseDelegate(response.is_playable != 0);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
public static bool HasLicense()
|
|
322
|
+
{
|
|
323
|
+
if (lastIsLaunchedFromTapTapPCResult != 1)
|
|
324
|
+
{
|
|
325
|
+
throw new Exception("checkLicense must be invoked after IsLaunchedFromTapTapPC success");
|
|
326
|
+
}
|
|
327
|
+
return TapClientBridge.HasLicense();
|
|
328
|
+
}
|
|
329
|
+
|
|
292
330
|
|
|
293
331
|
// 初始化校验结果
|
|
294
332
|
private class TapInitResult
|
|
295
333
|
{
|
|
296
|
-
internal
|
|
334
|
+
internal int result;
|
|
297
335
|
internal string errorMsg;
|
|
298
336
|
|
|
299
337
|
internal bool needQuitGame = false;
|
|
300
338
|
|
|
301
|
-
public TapInitResult(
|
|
339
|
+
public TapInitResult(int result, string errorMsg)
|
|
302
340
|
{
|
|
303
341
|
this.result = result;
|
|
304
342
|
this.errorMsg = errorMsg;
|
|
@@ -29,7 +29,6 @@ namespace TapSDK.Core.Standalone
|
|
|
29
29
|
|
|
30
30
|
// client 信息是否匹配
|
|
31
31
|
internal static bool isClientInfoMatched = true;
|
|
32
|
-
internal static bool enableAutoEvent = true;
|
|
33
32
|
|
|
34
33
|
internal static TapGatekeeper gatekeeperData = new TapGatekeeper();
|
|
35
34
|
|
|
@@ -96,7 +95,6 @@ namespace TapSDK.Core.Standalone
|
|
|
96
95
|
try
|
|
97
96
|
{
|
|
98
97
|
TapGatekeeper tapGatekeeper = JsonConvert.DeserializeObject<TapGatekeeper>(clientSettings);
|
|
99
|
-
SetAutoEvent(tapGatekeeper);
|
|
100
98
|
if (tapGatekeeper.Switch?.Heartbeat == true)
|
|
101
99
|
{
|
|
102
100
|
TapAppDurationStandalone.Enable();
|
|
@@ -120,7 +118,7 @@ namespace TapSDK.Core.Standalone
|
|
|
120
118
|
{
|
|
121
119
|
if (coreOptions == null)
|
|
122
120
|
{
|
|
123
|
-
|
|
121
|
+
TapLog.Log("coreOptions is null");
|
|
124
122
|
return;
|
|
125
123
|
}
|
|
126
124
|
TapLog.Log("UpdateLanguage called with language: " + language);
|
|
@@ -163,7 +161,6 @@ namespace TapSDK.Core.Standalone
|
|
|
163
161
|
json: body,
|
|
164
162
|
onSuccess: (data) =>
|
|
165
163
|
{
|
|
166
|
-
SetAutoEvent(data);
|
|
167
164
|
if (data.Switch?.Heartbeat == true)
|
|
168
165
|
{
|
|
169
166
|
TapAppDurationStandalone.Enable();
|
|
@@ -199,17 +196,6 @@ namespace TapSDK.Core.Standalone
|
|
|
199
196
|
File.WriteAllText(Path.Combine(Application.persistentDataPath, Constants.ClientSettingsFileName + "_" + TapTapSDK.taptapSdkOptions.clientId + ".json"), json);
|
|
200
197
|
}
|
|
201
198
|
|
|
202
|
-
private void SetAutoEvent(TapGatekeeper gatekeeper)
|
|
203
|
-
{
|
|
204
|
-
if (gatekeeper != null)
|
|
205
|
-
{
|
|
206
|
-
var switchData = gatekeeper.Switch;
|
|
207
|
-
if (switchData != null)
|
|
208
|
-
{
|
|
209
|
-
enableAutoEvent = switchData.AutoEvent;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
199
|
|
|
214
200
|
public static bool CheckInitState()
|
|
215
201
|
{
|
|
@@ -56,7 +56,7 @@ namespace TapSDK.Core.Standalone
|
|
|
56
56
|
}
|
|
57
57
|
if (!IsValidUserID(userID))
|
|
58
58
|
{
|
|
59
|
-
|
|
59
|
+
TapLog.Error("Invalid user ID, length should be 1-160 and only contains a-zA-Z0-9_+/=.,:");
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -103,7 +103,7 @@ namespace TapSDK.Core.Standalone
|
|
|
103
103
|
// name 长度256非空,不符合的丢事件,打log
|
|
104
104
|
if (!checkLength(name))
|
|
105
105
|
{
|
|
106
|
-
|
|
106
|
+
TapLog.Error(name + " Event name length should be less than or equal to 256 characters.");
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
|
|
@@ -207,12 +207,12 @@ namespace TapSDK.Core.Standalone
|
|
|
207
207
|
}
|
|
208
208
|
if (!checkLength(key))
|
|
209
209
|
{
|
|
210
|
-
|
|
210
|
+
TapLog.Error(key + " Property key length should be less than or equal to 256 characters.");
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
213
|
if (!checkLength(value))
|
|
214
214
|
{
|
|
215
|
-
|
|
215
|
+
TapLog.Error(value + " Property value length should be less than or equal to 256 characters.");
|
|
216
216
|
return;
|
|
217
217
|
}
|
|
218
218
|
Tracker.AddCommonProperty(key, value);
|
|
@@ -287,7 +287,7 @@ namespace TapSDK.Core.Standalone
|
|
|
287
287
|
}
|
|
288
288
|
if (amount <= 0 || amount > 100000000000)
|
|
289
289
|
{
|
|
290
|
-
|
|
290
|
+
TapLog.Error(amount + " is invalid, amount should be in range (0, 100000000000]");
|
|
291
291
|
return;
|
|
292
292
|
}
|
|
293
293
|
Tracker.LogPurchasedEvent(orderID, productName, amount, currencyType, paymentMethod, properties);
|
|
@@ -313,7 +313,7 @@ namespace TapSDK.Core.Standalone
|
|
|
313
313
|
/// <param name="value">oaid</param>
|
|
314
314
|
public void SetOAID(string value)
|
|
315
315
|
{
|
|
316
|
-
|
|
316
|
+
TapLog.Log("SetOAID called in PC platform (empty implementation)");
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
/// <summary>
|
|
@@ -321,7 +321,7 @@ namespace TapSDK.Core.Standalone
|
|
|
321
321
|
/// </summary>
|
|
322
322
|
public void LogDeviceLoginEvent()
|
|
323
323
|
{
|
|
324
|
-
|
|
324
|
+
TapLog.Log("LogDeviceLoginEvent called in PC platform (empty implementation)");
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
/// <summary>
|
|
@@ -402,12 +402,12 @@ namespace TapSDK.Core.Standalone
|
|
|
402
402
|
{
|
|
403
403
|
if (property.Key.Length <= 0 || property.Key.Length > 256)
|
|
404
404
|
{
|
|
405
|
-
|
|
405
|
+
TapLog.Log(property.Key + " Property key length should be more then 0 and less than or equal to 256 characters.");
|
|
406
406
|
continue;
|
|
407
407
|
}
|
|
408
408
|
if (property.Value.ToString().Length > 256)
|
|
409
409
|
{
|
|
410
|
-
|
|
410
|
+
TapLog.Log(property.Value + " Property value length should be less than or equal to 256 characters.");
|
|
411
411
|
continue;
|
|
412
412
|
}
|
|
413
413
|
filteredProperties.Add(property.Key, property.Value);
|
package/link.xml.meta
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
"name": "com.taptap.sdk.core",
|
|
3
|
+
"displayName": "TapTapSDK Core",
|
|
4
|
+
"description": "TapTapSDK Core",
|
|
5
|
+
"version": "4.8.1",
|
|
6
|
+
"unity": "2019.4",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"com.google.external-dependency-manager": "1.2.179"
|
|
10
|
+
}
|
|
11
11
|
}
|