com.taptap.sdk.license 4.7.0 → 4.7.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/Runtime/TapLicenseMobile.cs +5 -0
- package/Mobile/Runtime/TapSDK.License.Mobile.Runtime.asmdef +1 -2
- package/Runtime/Internal/ITapLicenseBridge.cs +2 -0
- package/Runtime/Internal/TapLicenseInitTask.cs +22 -0
- package/Runtime/Internal/TapLicenseInitTask.cs.meta +11 -0
- package/Runtime/Public/ITapLicenseCallback.cs +4 -1
- package/Runtime/Public/TapTapLicense.cs +14 -3
- package/Runtime/TapSDK.License.Runtime.asmdef +5 -1
- package/Standalone/Runtime/TapLicenseStandalone.cs +200 -13
- package/Standalone/Runtime/TapLicenseTracker.cs +106 -0
- package/Standalone/Runtime/TapLicenseTracker.cs.meta +11 -0
- package/Standalone/Runtime/TapSDK.License.Standalone.Runtime.asmdef +2 -4
- package/package.json +2 -2
|
@@ -17,6 +17,11 @@ namespace TapSDK.License.Mobile
|
|
|
17
17
|
EngineBridge.GetInstance().Register(TDS_LICENSE_SERVICE_CLZ, TDS_LICENSE_SERVICE_IMPL);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
public void Init()
|
|
21
|
+
{
|
|
22
|
+
// Android 原生内部处理
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
public void RegisterLicencesCallback(ITapLicenseCallback callback)
|
|
21
26
|
{
|
|
22
27
|
var command = new Command.Builder()
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
using TapSDK.Core;
|
|
2
|
+
using TapSDK.Core.Internal.Init;
|
|
3
|
+
|
|
4
|
+
#if PLATFORM_STANDALONE_WIN
|
|
5
|
+
namespace TapSDK.License.Internal
|
|
6
|
+
{
|
|
7
|
+
internal class TapLicenseInitTask : IInitTask
|
|
8
|
+
{
|
|
9
|
+
public int Order => 13;
|
|
10
|
+
|
|
11
|
+
public void Init(TapTapSdkOptions coreOption, TapTapSdkBaseOptions[] otherOptions)
|
|
12
|
+
{
|
|
13
|
+
TapTapLicense.Init();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public void Init(TapTapSdkOptions coreOption)
|
|
17
|
+
{
|
|
18
|
+
TapTapLicense.Init();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
#endif
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
using TapSDK.License.Internal;
|
|
2
2
|
using TapSDK.Core.Internal.Utils;
|
|
3
|
+
using System;
|
|
4
|
+
using UnityEngine.PlayerLoop;
|
|
5
|
+
using TapSDK.Core;
|
|
3
6
|
|
|
4
7
|
namespace TapSDK.License {
|
|
5
8
|
public class TapTapLicense {
|
|
6
9
|
|
|
7
|
-
public static readonly string Version = "4.7.
|
|
10
|
+
public static readonly string Version = "4.7.1";
|
|
8
11
|
|
|
9
12
|
static readonly ITapLicenseBridge license;
|
|
10
13
|
|
|
@@ -13,7 +16,13 @@ namespace TapSDK.License {
|
|
|
13
16
|
as ITapLicenseBridge;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
internal static void Init()
|
|
20
|
+
{
|
|
21
|
+
license.Init();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static void RegisterLicenseCallBack(ITapLicenseCallback callback)
|
|
25
|
+
{
|
|
17
26
|
license.RegisterLicencesCallback(callback);
|
|
18
27
|
}
|
|
19
28
|
|
|
@@ -40,7 +49,9 @@ namespace TapSDK.License {
|
|
|
40
49
|
license.PurchaseDLC(dlc);
|
|
41
50
|
}
|
|
42
51
|
|
|
43
|
-
|
|
52
|
+
[Obsolete("No longer needed with new TapTap client and will be removed in the future")]
|
|
53
|
+
public static void SetTestEnvironment(bool isTest)
|
|
54
|
+
{
|
|
44
55
|
license.SetTestEnvironment(isTest);
|
|
45
56
|
}
|
|
46
57
|
|
|
@@ -1,42 +1,229 @@
|
|
|
1
1
|
using TapSDK.License;
|
|
2
2
|
using TapSDK.License.Internal;
|
|
3
3
|
using TapSDK.Core;
|
|
4
|
+
using TapSDK.Core.Standalone;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using System;
|
|
7
|
+
using UnityEngine.Animations;
|
|
8
|
+
using System.Linq;
|
|
4
9
|
|
|
10
|
+
#if PLATFORM_STANDALONE_WIN
|
|
5
11
|
namespace TapSDK.License.Standalone {
|
|
6
|
-
|
|
12
|
+
|
|
13
|
+
public class TapLicenseStandalone : ITapLicenseBridge
|
|
14
|
+
{
|
|
15
|
+
|
|
16
|
+
private List<ITapDlcCallback> currentDLCCallbacks;
|
|
17
|
+
|
|
18
|
+
private List<ITapLicenseCallback> currentLicenseCallbacks;
|
|
19
|
+
|
|
20
|
+
// 是否已在 dll 层注册回调
|
|
21
|
+
private bool HasRegisterNativeDLCCallback = false;
|
|
22
|
+
|
|
23
|
+
private bool HasRegisterNativeLicenseCallback = false;
|
|
24
|
+
|
|
25
|
+
private string currentSessionId = null;
|
|
26
|
+
|
|
27
|
+
public void Init()
|
|
28
|
+
{
|
|
29
|
+
TaplicenseTracker.Instance.TrackInit();
|
|
30
|
+
}
|
|
7
31
|
public void CheckLicense()
|
|
8
32
|
{
|
|
9
|
-
|
|
33
|
+
if (!CheckInit())
|
|
34
|
+
{
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
currentSessionId = Guid.NewGuid().ToString();
|
|
38
|
+
string method = "checkLicense";
|
|
39
|
+
Dictionary<string, string> props = new Dictionary<string, string> { { "license_type", "tap_license" } };
|
|
40
|
+
TaplicenseTracker.Instance.TrackStart(method, currentSessionId, props);
|
|
41
|
+
bool isOwned = false;
|
|
42
|
+
try
|
|
43
|
+
{
|
|
44
|
+
isOwned = TapClientStandalone.HasLicense();
|
|
45
|
+
}
|
|
46
|
+
catch (Exception e)
|
|
47
|
+
{
|
|
48
|
+
TaplicenseTracker.Instance.TrackFailure(method, currentSessionId, props, -1, e.Message ?? "");
|
|
49
|
+
throw ;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (isOwned)
|
|
53
|
+
{
|
|
54
|
+
TaplicenseTracker.Instance.TrackSuccess(method, currentSessionId, props);
|
|
55
|
+
}
|
|
56
|
+
else
|
|
57
|
+
{
|
|
58
|
+
TaplicenseTracker.Instance.TrackFailure(method, currentSessionId, props, 0, "NOT_PURCHASED");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (currentLicenseCallbacks != null)
|
|
62
|
+
{
|
|
63
|
+
foreach (ITapLicenseCallback callback in currentLicenseCallbacks)
|
|
64
|
+
{
|
|
65
|
+
if (isOwned)
|
|
66
|
+
{
|
|
67
|
+
callback?.OnLicenseSuccess();
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
{
|
|
71
|
+
callback?.OnLicenseFailed();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
10
76
|
}
|
|
11
77
|
|
|
12
78
|
public void CheckLicenseForcibly()
|
|
13
79
|
{
|
|
14
|
-
|
|
80
|
+
CheckLicense();
|
|
15
81
|
}
|
|
16
82
|
|
|
17
|
-
public void PurchaseDLC(string sku) {
|
|
18
|
-
TapLogger.Warn($"{nameof(PurchaseDLC)} NOT implemented.");
|
|
19
|
-
}
|
|
20
83
|
|
|
21
|
-
public void QueryDLC(string[] skus)
|
|
22
|
-
|
|
84
|
+
public void QueryDLC(string[] skus)
|
|
85
|
+
{
|
|
86
|
+
if (!CheckInit())
|
|
87
|
+
{
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (skus.Length == 0)
|
|
91
|
+
{
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
currentSessionId = Guid.NewGuid().ToString();
|
|
95
|
+
string method = "queryDLC";
|
|
96
|
+
Dictionary<string, string> props = new Dictionary<string, string> { { "sku_ids", string.Join(",", skus) } };
|
|
97
|
+
TaplicenseTracker.Instance.TrackStart(method, currentSessionId, props);
|
|
98
|
+
Dictionary<string, object> dlcResult = new Dictionary<string, object>();
|
|
99
|
+
try
|
|
100
|
+
{
|
|
101
|
+
foreach (string skuId in skus)
|
|
102
|
+
{
|
|
103
|
+
bool isOwned = TapClientStandalone.QueryDLC(skuId);
|
|
104
|
+
dlcResult.Add(skuId, isOwned ? 1 : 0);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (Exception e)
|
|
108
|
+
{
|
|
109
|
+
TaplicenseTracker.Instance.TrackFailure(method, currentSessionId, props, -1, e.Message ?? "");
|
|
110
|
+
throw ;
|
|
111
|
+
}
|
|
112
|
+
TaplicenseTracker.Instance.TrackSuccess(method, currentSessionId, props);
|
|
113
|
+
if (currentDLCCallbacks != null)
|
|
114
|
+
{
|
|
115
|
+
foreach (ITapDlcCallback callback in currentDLCCallbacks)
|
|
116
|
+
{
|
|
117
|
+
callback?.OnQueryCallBack(TapLicenseQueryCode.QUERY_RESULT_OK, dlcResult);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
23
120
|
}
|
|
24
121
|
|
|
25
122
|
public void RegisterDLCCallback(ITapDlcCallback callback)
|
|
26
123
|
{
|
|
27
|
-
|
|
124
|
+
if (currentDLCCallbacks == null)
|
|
125
|
+
{
|
|
126
|
+
currentDLCCallbacks = new List<ITapDlcCallback>();
|
|
127
|
+
}
|
|
128
|
+
currentDLCCallbacks.Add(callback);
|
|
129
|
+
if (!HasRegisterNativeDLCCallback)
|
|
130
|
+
{
|
|
131
|
+
HasRegisterNativeDLCCallback = true;
|
|
132
|
+
TapClientStandalone.RegisterDLCOwnedCallback(DLCCallbackDelegate);
|
|
133
|
+
}
|
|
28
134
|
}
|
|
29
135
|
|
|
136
|
+
|
|
30
137
|
public void RegisterLicencesCallback(ITapLicenseCallback callback)
|
|
31
138
|
{
|
|
32
|
-
|
|
139
|
+
if (currentLicenseCallbacks == null)
|
|
140
|
+
{
|
|
141
|
+
currentLicenseCallbacks = new List<ITapLicenseCallback>();
|
|
142
|
+
}
|
|
143
|
+
currentLicenseCallbacks.Add(callback);
|
|
144
|
+
if (!HasRegisterNativeLicenseCallback)
|
|
145
|
+
{
|
|
146
|
+
HasRegisterNativeLicenseCallback = true;
|
|
147
|
+
TapClientStandalone.RegisterLicenseCallback(LicenseCallbackDelegate);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
public void SetTestEnvironment(bool isTest)
|
|
153
|
+
{
|
|
154
|
+
TapLogger.Warn($"{nameof(SetTestEnvironment)} NOT implemented.");
|
|
155
|
+
}
|
|
33
156
|
|
|
157
|
+
public void PurchaseDLC(string skuId)
|
|
158
|
+
{
|
|
159
|
+
if (!CheckInit())
|
|
160
|
+
{
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
currentSessionId = Guid.NewGuid().ToString();
|
|
164
|
+
string method = "purchaseDLC";
|
|
165
|
+
Dictionary<string, string> props = new Dictionary<string, string> { { "sku_id", skuId } };
|
|
166
|
+
TaplicenseTracker.Instance.TrackStart(method, currentSessionId, props);
|
|
167
|
+
bool isSuccess = false;
|
|
168
|
+
try
|
|
169
|
+
{
|
|
170
|
+
isSuccess = TapClientStandalone.ShowStore(skuId);
|
|
171
|
+
}
|
|
172
|
+
catch (Exception e)
|
|
173
|
+
{
|
|
174
|
+
TaplicenseTracker.Instance.TrackFailure(method, currentSessionId, props, -1, e.Message ?? "");
|
|
175
|
+
throw;
|
|
176
|
+
}
|
|
177
|
+
if (isSuccess)
|
|
178
|
+
{
|
|
179
|
+
TaplicenseTracker.Instance.TrackSuccess(method, currentSessionId, props);
|
|
180
|
+
}
|
|
181
|
+
else
|
|
182
|
+
{
|
|
183
|
+
TaplicenseTracker.Instance.TrackFailure(method, currentSessionId, props, -1, "ShowStoreFailed");
|
|
184
|
+
}
|
|
34
185
|
}
|
|
35
186
|
|
|
36
|
-
|
|
37
|
-
|
|
187
|
+
private void DLCCallbackDelegate(string skuId, bool isOwned)
|
|
188
|
+
{
|
|
189
|
+
if (currentDLCCallbacks != null)
|
|
190
|
+
{
|
|
191
|
+
foreach (ITapDlcCallback callback in currentDLCCallbacks)
|
|
192
|
+
{
|
|
193
|
+
callback?.OnOrderCallBack(skuId, isOwned ? TapLicensePurchasedCode.DLC_PURCHASED : TapLicensePurchasedCode.DLC_NOT_PURCHASED);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
private void LicenseCallbackDelegate(bool isOwned)
|
|
200
|
+
{
|
|
201
|
+
if (currentLicenseCallbacks != null)
|
|
202
|
+
{
|
|
203
|
+
foreach (ITapLicenseCallback callback in currentLicenseCallbacks)
|
|
204
|
+
{
|
|
205
|
+
if (isOwned)
|
|
206
|
+
{
|
|
207
|
+
callback?.OnLicenseSuccess();
|
|
208
|
+
}
|
|
209
|
+
else
|
|
210
|
+
{
|
|
211
|
+
callback?.OnLicenseFailed();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
private bool CheckInit()
|
|
219
|
+
{
|
|
220
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
221
|
+
{
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
return true;
|
|
38
225
|
}
|
|
39
226
|
|
|
40
|
-
|
|
41
227
|
}
|
|
42
228
|
}
|
|
229
|
+
#endif
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using System.Linq;
|
|
3
|
+
using Newtonsoft.Json;
|
|
4
|
+
using TapSDK.Core.Standalone.Internal.Openlog;
|
|
5
|
+
|
|
6
|
+
namespace TapSDK.License.Standalone
|
|
7
|
+
{
|
|
8
|
+
internal class TaplicenseTracker
|
|
9
|
+
{
|
|
10
|
+
private const string ACTION_INIT = "init";
|
|
11
|
+
private const string ACTION_START = "start";
|
|
12
|
+
private const string ACTION_SUCCESS = "success";
|
|
13
|
+
private const string ACTION_FAIL = "fail";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
private static TaplicenseTracker instance;
|
|
18
|
+
|
|
19
|
+
private TapOpenlogStandalone openlog;
|
|
20
|
+
|
|
21
|
+
private TaplicenseTracker()
|
|
22
|
+
{
|
|
23
|
+
openlog = new TapOpenlogStandalone("TapLicense", TapTapLicense.Version);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static TaplicenseTracker Instance
|
|
27
|
+
{
|
|
28
|
+
get
|
|
29
|
+
{
|
|
30
|
+
if (instance == null)
|
|
31
|
+
{
|
|
32
|
+
instance = new TaplicenseTracker();
|
|
33
|
+
}
|
|
34
|
+
return instance;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
internal void TrackInit()
|
|
39
|
+
{
|
|
40
|
+
ReportLog(ACTION_INIT);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
internal void TrackStart(string funcName, string seesionId, Dictionary<string, string> props = null)
|
|
44
|
+
{
|
|
45
|
+
Dictionary<string, string> parameters = new Dictionary<string, string>
|
|
46
|
+
{
|
|
47
|
+
{ "func_name", funcName },
|
|
48
|
+
{ "session_id", seesionId },
|
|
49
|
+
};
|
|
50
|
+
if (props != null) {
|
|
51
|
+
foreach (var item in props)
|
|
52
|
+
{
|
|
53
|
+
parameters.Add(item.Key, item.Value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
ReportLog(ACTION_START, new Dictionary<string, string>()
|
|
57
|
+
{
|
|
58
|
+
{ "args", JsonConvert.SerializeObject(parameters) }
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
internal void TrackSuccess(string funcName, string seesionId, Dictionary<string, string> props = null)
|
|
63
|
+
{
|
|
64
|
+
Dictionary<string, string> parameters = new Dictionary<string, string>
|
|
65
|
+
{
|
|
66
|
+
{ "func_name", funcName },
|
|
67
|
+
{ "session_id", seesionId },
|
|
68
|
+
};
|
|
69
|
+
if (props != null) {
|
|
70
|
+
foreach (var item in props)
|
|
71
|
+
{
|
|
72
|
+
parameters.Add(item.Key, item.Value);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
ReportLog(ACTION_SUCCESS, new Dictionary<string, string>()
|
|
76
|
+
{
|
|
77
|
+
{ "args", JsonConvert.SerializeObject(parameters) }
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
internal void TrackFailure(string funcName, string seesionId, Dictionary<string, string> props = null, int errorCode = -1, string errorMessage = null)
|
|
82
|
+
{
|
|
83
|
+
Dictionary<string, string> parameters = new Dictionary<string, string>
|
|
84
|
+
{
|
|
85
|
+
{ "func_name", funcName },
|
|
86
|
+
{ "session_id", seesionId },
|
|
87
|
+
{ "error_code", errorCode.ToString() },
|
|
88
|
+
{ "error_msg", errorMessage }
|
|
89
|
+
};
|
|
90
|
+
if (props != null) {
|
|
91
|
+
foreach (var item in props)
|
|
92
|
+
{
|
|
93
|
+
parameters.Add(item.Key, item.Value);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
ReportLog(ACTION_FAIL, new Dictionary<string, string>()
|
|
97
|
+
{
|
|
98
|
+
{ "args", JsonConvert.SerializeObject(parameters) }
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
private void ReportLog(string action, Dictionary<string, string> parameters = null)
|
|
102
|
+
{
|
|
103
|
+
openlog.LogBusiness(action, parameters);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
"name": "TapSDK.License.Standalone.Runtime",
|
|
3
3
|
"references": [
|
|
4
4
|
"GUID:6f31234cd7bae42d2ae6f8b300cad891",
|
|
5
|
-
"GUID:7d5ef2062f3704e1ab74aac0e4d5a1a7"
|
|
5
|
+
"GUID:7d5ef2062f3704e1ab74aac0e4d5a1a7",
|
|
6
|
+
"GUID:cdf1346592073467a860c3effd9679d4"
|
|
6
7
|
],
|
|
7
8
|
"includePlatforms": [
|
|
8
9
|
"Editor",
|
|
9
|
-
"LinuxStandalone64",
|
|
10
|
-
"macOSStandalone",
|
|
11
|
-
"WindowsStandalone32",
|
|
12
10
|
"WindowsStandalone64"
|
|
13
11
|
],
|
|
14
12
|
"excludePlatforms": [],
|
package/package.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"name": "com.taptap.sdk.license",
|
|
3
3
|
"displayName": "TapTapSDK License",
|
|
4
4
|
"description": "TapTapSDK License",
|
|
5
|
-
"version": "4.7.
|
|
5
|
+
"version": "4.7.1",
|
|
6
6
|
"unity": "2019.4",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"com.taptap.sdk.core": "4.7.
|
|
9
|
+
"com.taptap.sdk.core": "4.7.1"
|
|
10
10
|
}
|
|
11
11
|
}
|