com.taptap.sdk.core 4.7.0-alpha.14 → 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/Editor/NativeDependencies.xml +2 -3
- package/Resources/TapMessage.prefab +8 -8
- package/Runtime/Public/DataStorage.cs +15 -3
- package/Runtime/Public/TapTapSDK.cs +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/Runtime/Internal/TapClientBridge.cs +221 -139
- package/Standalone/Runtime/Internal/UI/TapClientConnectTipController.cs +6 -6
- package/Standalone/Runtime/Public/TapClientStandalone.cs +149 -84
- package/link.xml +4 -0
- package/link.xml.meta +7 -0
- package/package.json +1 -1
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
<androidPackages>
|
|
4
4
|
<repositories>
|
|
5
5
|
<repository>https://repo.maven.apache.org/maven2</repository>
|
|
6
|
-
<repository>https://nexus.xmxdev.com/repository/maven-public</repository>
|
|
7
6
|
</repositories>
|
|
8
|
-
<androidPackage spec="com.taptap.sdk:tap-core-unity:4.7.0
|
|
7
|
+
<androidPackage spec="com.taptap.sdk:tap-core-unity:4.7.0"/>
|
|
9
8
|
</androidPackages>
|
|
10
9
|
<iosPods>
|
|
11
10
|
<sources>
|
|
12
11
|
<source>https://github.com/CocoaPods/Specs.git</source>
|
|
13
12
|
</sources>
|
|
14
|
-
<iosPod name="TapTapCoreSDK" version="~> 4.
|
|
13
|
+
<iosPod name="TapTapCoreSDK" version="~> 4.7.1" bitcodeEnabled="false" addToAllTargets="false"/>
|
|
15
14
|
</iosPods>
|
|
16
15
|
</dependencies>
|
|
@@ -133,7 +133,7 @@ RectTransform:
|
|
|
133
133
|
m_AnchorMin: {x: 0.5, y: 0}
|
|
134
134
|
m_AnchorMax: {x: 0.5, y: 0}
|
|
135
135
|
m_AnchoredPosition: {x: 0.5, y: 100}
|
|
136
|
-
m_SizeDelta: {x:
|
|
136
|
+
m_SizeDelta: {x: 200, y: 40}
|
|
137
137
|
m_Pivot: {x: 0.5, y: 0.5}
|
|
138
138
|
--- !u!1 &6224477040733538127
|
|
139
139
|
GameObject:
|
|
@@ -172,8 +172,8 @@ RectTransform:
|
|
|
172
172
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
173
173
|
m_AnchorMin: {x: 0.5, y: 1}
|
|
174
174
|
m_AnchorMax: {x: 0.5, y: 1}
|
|
175
|
-
m_AnchoredPosition: {x: 0, y: -
|
|
176
|
-
m_SizeDelta: {x:
|
|
175
|
+
m_AnchoredPosition: {x: 0, y: -20}
|
|
176
|
+
m_SizeDelta: {x: 200, y: 40}
|
|
177
177
|
m_Pivot: {x: 0.5, y: 0.5}
|
|
178
178
|
--- !u!222 &6150942826548885810
|
|
179
179
|
CanvasRenderer:
|
|
@@ -202,7 +202,7 @@ MonoBehaviour:
|
|
|
202
202
|
m_OnCullStateChanged:
|
|
203
203
|
m_PersistentCalls:
|
|
204
204
|
m_Calls: []
|
|
205
|
-
m_Sprite: {fileID: 21300000, guid:
|
|
205
|
+
m_Sprite: {fileID: 21300000, guid: 121fadaa5f515439bb5fa46c7f9d2c2c, type: 3}
|
|
206
206
|
m_Type: 1
|
|
207
207
|
m_PreserveAspect: 0
|
|
208
208
|
m_FillCenter: 1
|
|
@@ -286,8 +286,8 @@ RectTransform:
|
|
|
286
286
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
287
287
|
m_AnchorMin: {x: 0, y: 1}
|
|
288
288
|
m_AnchorMax: {x: 0, y: 1}
|
|
289
|
-
m_AnchoredPosition: {x:
|
|
290
|
-
m_SizeDelta: {x:
|
|
289
|
+
m_AnchoredPosition: {x: 100, y: -20}
|
|
290
|
+
m_SizeDelta: {x: 180, y: 35}
|
|
291
291
|
m_Pivot: {x: 0.5, y: 0.5}
|
|
292
292
|
--- !u!222 &6511217540227465427
|
|
293
293
|
CanvasRenderer:
|
|
@@ -317,8 +317,8 @@ MonoBehaviour:
|
|
|
317
317
|
m_PersistentCalls:
|
|
318
318
|
m_Calls: []
|
|
319
319
|
m_FontData:
|
|
320
|
-
m_Font: {fileID:
|
|
321
|
-
m_FontSize:
|
|
320
|
+
m_Font: {fileID: 12800000, guid: c76570f7b9a4942ae84d6491f2669330, type: 3}
|
|
321
|
+
m_FontSize: 11
|
|
322
322
|
m_FontStyle: 0
|
|
323
323
|
m_BestFit: 0
|
|
324
324
|
m_MinSize: 0
|
|
@@ -16,7 +16,8 @@ namespace TapSDK.Core
|
|
|
16
16
|
{
|
|
17
17
|
string storageKey = GenerateStorageKey(key);
|
|
18
18
|
SaveStringToCache(storageKey, value);
|
|
19
|
-
|
|
19
|
+
string encodeValue = EncodeString(value);
|
|
20
|
+
PlayerPrefs.SetString(storageKey, encodeValue);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
public static string LoadString(string key)
|
|
@@ -29,10 +30,12 @@ namespace TapSDK.Core
|
|
|
29
30
|
}
|
|
30
31
|
value = PlayerPrefs.HasKey(storageKey) ? DecodeString(PlayerPrefs.GetString(storageKey)) : null;
|
|
31
32
|
// 尝试从本地获取旧版本数据
|
|
32
|
-
if (value == null)
|
|
33
|
+
if (value == null)
|
|
34
|
+
{
|
|
33
35
|
value = PlayerPrefs.HasKey(key) ? DecodeString(PlayerPrefs.GetString(key)) : null;
|
|
34
36
|
// 旧版本存在有效数据时,转储为新的 storageKey
|
|
35
|
-
if (value != null)
|
|
37
|
+
if (value != null)
|
|
38
|
+
{
|
|
36
39
|
PlayerPrefs.SetString(storageKey, EncodeString(value));
|
|
37
40
|
PlayerPrefs.DeleteKey(key);
|
|
38
41
|
}
|
|
@@ -44,6 +47,15 @@ namespace TapSDK.Core
|
|
|
44
47
|
return value;
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
public static void RemoveCacheKey(string key)
|
|
51
|
+
{
|
|
52
|
+
if (!string.IsNullOrEmpty(key))
|
|
53
|
+
{
|
|
54
|
+
PlayerPrefs.DeleteKey(key);
|
|
55
|
+
PlayerPrefs.DeleteKey(GenerateStorageKey(key));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
47
59
|
private static void SaveStringToCache(string key, string value)
|
|
48
60
|
{
|
|
49
61
|
if (dataCache == null)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -22,28 +22,30 @@ namespace TapSDK.Core.Standalone.Internal
|
|
|
22
22
|
// 已安装 TapTap,游戏未通过 TapTap 启动
|
|
23
23
|
NotLaunchedByPlatform = 3,
|
|
24
24
|
|
|
25
|
+
// 平台版本不匹配,请引导用户升级 TapTap 与游戏至最新版本,再重新运行游戏
|
|
26
|
+
PlatformVersionMismatch = 4,
|
|
27
|
+
|
|
25
28
|
// SDK 本地执行时未知错误
|
|
26
|
-
Unknown = -1
|
|
27
|
-
|
|
28
|
-
Timeout = -2,
|
|
29
|
+
Unknown = -1
|
|
30
|
+
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
internal enum TapEventID
|
|
32
34
|
{
|
|
33
|
-
|
|
35
|
+
AuthorizeFinished_internal = 2001,
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
SystemStateChanged = 1,
|
|
37
|
+
AuthorizeFinished = 2002,
|
|
37
38
|
|
|
38
|
-
// [
|
|
39
|
-
|
|
39
|
+
// [4001, 6000), reserved for TapTap ownership events
|
|
40
|
+
GamePlayableStatusChanged = 4001,
|
|
41
|
+
DLCPlayableStatusChanged = 4002,
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
// 系统事件类型
|
|
43
45
|
internal enum SystemState
|
|
44
46
|
{
|
|
45
|
-
kSystemState_Unknown = 0,
|
|
46
|
-
kSystemState_PlatformExit = 1,
|
|
47
|
+
kSystemState_Unknown = 0, // 未知
|
|
48
|
+
kSystemState_PlatformExit = 1, // 平台退出
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
// 是否触发授权的返回结果
|
|
@@ -67,162 +69,242 @@ namespace TapSDK.Core.Standalone.Internal
|
|
|
67
69
|
{
|
|
68
70
|
|
|
69
71
|
#if UNITY_STANDALONE_WIN
|
|
70
|
-
|
|
72
|
+
public const string DLL_NAME = "taptap_api";
|
|
71
73
|
#endif
|
|
72
74
|
|
|
73
75
|
#if UNITY_STANDALONE_WIN
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
78
|
-
internal static extern int TapSDK_Init(StringBuilder errMsg, [MarshalAs( UnmanagedType.LPStr )]string pubKey);
|
|
79
|
-
|
|
80
|
-
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
81
|
-
internal static extern void TapSDK_Shutdown();
|
|
82
|
-
|
|
83
|
-
// 定义与 C 兼容的委托
|
|
84
|
-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
85
|
-
internal delegate void CallbackDelegate(int id, IntPtr userData);
|
|
86
|
-
|
|
87
|
-
// 系统状态返回结果结构体
|
|
88
|
-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
89
|
-
internal struct SystemStateResponse
|
|
90
|
-
{
|
|
91
|
-
public SystemState state; // 枚举直接映射
|
|
92
|
-
}
|
|
76
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
77
|
+
internal static extern bool TapSDK_RestartAppIfNecessary([MarshalAs(UnmanagedType.LPStr)] string clientId);
|
|
93
78
|
|
|
94
|
-
|
|
95
|
-
|
|
79
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
80
|
+
internal static extern int TapSDK_Init(StringBuilder errMsg, [MarshalAs(UnmanagedType.LPStr)] string pubKey);
|
|
96
81
|
|
|
97
|
-
|
|
98
|
-
|
|
82
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
83
|
+
internal static extern void TapSDK_Shutdown();
|
|
99
84
|
|
|
100
|
-
|
|
101
|
-
|
|
85
|
+
// 定义与 C 兼容的委托
|
|
86
|
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
87
|
+
internal delegate void CallbackDelegate(int id, IntPtr userData);
|
|
102
88
|
|
|
89
|
+
// 系统状态返回结果结构体
|
|
90
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
91
|
+
internal struct SystemStateResponse
|
|
92
|
+
{
|
|
93
|
+
public SystemState state; // 枚举直接映射
|
|
94
|
+
}
|
|
103
95
|
|
|
104
|
-
|
|
96
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
97
|
+
internal static extern void TapSDK_RegisterCallback(int callbackId, IntPtr callback);
|
|
105
98
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
public struct AuthorizeFinishedResponse
|
|
109
|
-
{
|
|
110
|
-
public int is_cancel ; // 是否取消
|
|
99
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
100
|
+
internal static extern void TapSDK_RunCallbacks();
|
|
111
101
|
|
|
112
|
-
[
|
|
113
|
-
|
|
102
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
103
|
+
internal static extern void TapSDK_UnregisterCallback(int callbackId, IntPtr callback);
|
|
114
104
|
|
|
115
|
-
}
|
|
116
105
|
|
|
117
|
-
|
|
118
|
-
internal static extern bool TapUser_GetOpenID(StringBuilder openId);
|
|
106
|
+
// 登录相关接口
|
|
119
107
|
|
|
120
|
-
|
|
121
|
-
|
|
108
|
+
// 授权返回结果结构体
|
|
109
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
110
|
+
public struct AuthorizeFinishedResponse
|
|
111
|
+
{
|
|
112
|
+
public int is_cancel; // 是否取消
|
|
122
113
|
|
|
114
|
+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
|
|
115
|
+
public string callback_uri; // 256 字节的 C 端字符串
|
|
123
116
|
|
|
124
|
-
|
|
125
|
-
internal static extern int TapUser_AsyncAuthorize([MarshalAs( UnmanagedType.LPStr )] string scopeStrings, [MarshalAs( UnmanagedType.LPStr )] string responseType,
|
|
126
|
-
[MarshalAs( UnmanagedType.LPStr )] string redirectUri, [MarshalAs( UnmanagedType.LPStr )] string codeChallenge, [MarshalAs( UnmanagedType.LPStr )] string state,
|
|
127
|
-
[MarshalAs( UnmanagedType.LPStr )] string codeChallengeMethod, [MarshalAs( UnmanagedType.LPStr )] string versonCode, [MarshalAs( UnmanagedType.LPStr )] string sdkUa, [MarshalAs( UnmanagedType.LPStr )] string info);
|
|
117
|
+
}
|
|
128
118
|
|
|
119
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
120
|
+
internal static extern bool TapUser_GetOpenID(StringBuilder openId);
|
|
129
121
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
{
|
|
133
|
-
StringBuilder errMsgBuffer = new StringBuilder(1024); // 分配 1024 字节缓冲区
|
|
134
|
-
int result = TapSDK_Init(errMsgBuffer, key);
|
|
135
|
-
errMessage = errMsgBuffer.ToString();
|
|
136
|
-
TapLogger.Debug("CheckInitState result = " + result);
|
|
137
|
-
return (TapSDKInitResult)result;
|
|
138
|
-
}
|
|
122
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
123
|
+
internal static extern bool TapSDK_GetClientID(StringBuilder clientId);
|
|
139
124
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
125
|
+
|
|
126
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
127
|
+
internal static extern int TapUser_AsyncAuthorize_internal([MarshalAs(UnmanagedType.LPStr)] string scopeStrings, [MarshalAs(UnmanagedType.LPStr)] string responseType,
|
|
128
|
+
[MarshalAs(UnmanagedType.LPStr)] string redirectUri, [MarshalAs(UnmanagedType.LPStr)] string codeChallenge, [MarshalAs(UnmanagedType.LPStr)] string state,
|
|
129
|
+
[MarshalAs(UnmanagedType.LPStr)] string codeChallengeMethod, [MarshalAs(UnmanagedType.LPStr)] string versonCode, [MarshalAs(UnmanagedType.LPStr)] string sdkUa, [MarshalAs(UnmanagedType.LPStr)] string info);
|
|
130
|
+
|
|
131
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
132
|
+
internal static extern int TapUser_AsyncAuthorize([MarshalAs(UnmanagedType.LPStr)] string scopeStrings);
|
|
133
|
+
|
|
134
|
+
// DLC 接口
|
|
135
|
+
// 检查是否拥有当前游戏
|
|
136
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
137
|
+
internal static extern bool TapApps_IsOwned();
|
|
138
|
+
|
|
139
|
+
// 游戏本体可玩状态变更事件响应结构体
|
|
140
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
141
|
+
public struct GamePlayableStatusChangedResponse
|
|
142
|
+
{
|
|
143
|
+
public byte is_playable; // 游戏本体是否可玩
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// 显示指定 DLC 的商店页面
|
|
147
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
148
|
+
internal static extern bool TapDLC_ShowStore([MarshalAs(UnmanagedType.LPStr)] string dlcId);
|
|
149
|
+
|
|
150
|
+
// 查询用户是否拥有指定的 DLC
|
|
151
|
+
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
152
|
+
internal static extern bool TapDLC_IsOwned([MarshalAs(UnmanagedType.LPStr)] string dlcId);
|
|
153
|
+
|
|
154
|
+
// DLC 授权完成响应结果
|
|
155
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
156
|
+
public struct DLCPlayableStatusChangedResponse
|
|
160
157
|
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
_userCallbackInstance = callback;
|
|
167
|
-
break;
|
|
168
|
-
case TapEventID.SystemStateChanged:
|
|
169
|
-
if (_callbackInstance != null)
|
|
170
|
-
{
|
|
171
|
-
UnRegisterCallback(eventID, _callbackInstance);
|
|
172
|
-
}
|
|
173
|
-
_callbackInstance = callback; // 防止被 GC 回收
|
|
174
|
-
break;
|
|
158
|
+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
|
159
|
+
public string dlc_id; // DLC ID
|
|
160
|
+
|
|
161
|
+
public byte is_playable; // 是否可玩,当用户购买 DLC (外置 DLC 为购买且下载完成后),此值返回 true。其他情况返回 false
|
|
162
|
+
|
|
175
163
|
}
|
|
176
|
-
|
|
177
|
-
TapSDK_RegisterCallback((int)eventID, funcPtr);
|
|
178
|
-
}
|
|
179
164
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
{
|
|
183
|
-
|
|
184
|
-
IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(callback);
|
|
185
|
-
switch (eventID)
|
|
165
|
+
// 初始化检查
|
|
166
|
+
internal static int CheckInitState(out string errMessage, string key)
|
|
186
167
|
{
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
break;
|
|
168
|
+
StringBuilder errMsgBuffer = new StringBuilder(1024); // 分配 1024 字节缓冲区
|
|
169
|
+
int result = TapSDK_Init(errMsgBuffer, key);
|
|
170
|
+
errMessage = errMsgBuffer.ToString();
|
|
171
|
+
TapLogger.Debug("CheckInitState result = " + result);
|
|
172
|
+
return result;
|
|
193
173
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
174
|
+
|
|
175
|
+
// 预防 GC 回收的静态变量
|
|
176
|
+
private static CallbackDelegate _dlcCallbackInstance;
|
|
177
|
+
|
|
178
|
+
private static CallbackDelegate _userCallbackInternalInstance;
|
|
179
|
+
|
|
180
|
+
private static CallbackDelegate _userCallbackInstance;
|
|
181
|
+
|
|
182
|
+
private static CallbackDelegate _licenseCallbackInstance;
|
|
183
|
+
internal static void RegisterCallback(TapEventID eventID, CallbackDelegate callback)
|
|
201
184
|
{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
185
|
+
|
|
186
|
+
IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(callback);
|
|
187
|
+
switch (eventID)
|
|
188
|
+
{
|
|
189
|
+
case TapEventID.DLCPlayableStatusChanged:
|
|
190
|
+
if (_dlcCallbackInstance != null)
|
|
191
|
+
{
|
|
192
|
+
UnRegisterCallback(eventID, _dlcCallbackInstance);
|
|
193
|
+
}
|
|
194
|
+
_dlcCallbackInstance = callback;
|
|
195
|
+
break;
|
|
196
|
+
case TapEventID.GamePlayableStatusChanged:
|
|
197
|
+
if (_licenseCallbackInstance != null)
|
|
198
|
+
{
|
|
199
|
+
UnRegisterCallback(eventID, _licenseCallbackInstance);
|
|
200
|
+
}
|
|
201
|
+
_licenseCallbackInstance = callback;
|
|
202
|
+
break;
|
|
203
|
+
case TapEventID.AuthorizeFinished_internal:
|
|
204
|
+
if (_userCallbackInternalInstance != null)
|
|
205
|
+
{
|
|
206
|
+
UnRegisterCallback(eventID, _userCallbackInternalInstance);
|
|
207
|
+
}
|
|
208
|
+
_userCallbackInternalInstance = callback;
|
|
209
|
+
break;
|
|
210
|
+
case TapEventID.AuthorizeFinished:
|
|
211
|
+
if (_userCallbackInstance != null)
|
|
212
|
+
{
|
|
213
|
+
UnRegisterCallback(eventID, _userCallbackInstance);
|
|
214
|
+
}
|
|
215
|
+
_userCallbackInstance = callback;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
TapSDK_RegisterCallback((int)eventID, funcPtr);
|
|
210
220
|
}
|
|
211
|
-
}
|
|
212
221
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
openId = openIdBuffer.ToString();
|
|
217
|
-
return success;
|
|
218
|
-
}
|
|
222
|
+
// 移除回调
|
|
223
|
+
internal static void UnRegisterCallback(TapEventID eventID, CallbackDelegate callback)
|
|
224
|
+
{
|
|
219
225
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
+
IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(callback);
|
|
227
|
+
switch (eventID)
|
|
228
|
+
{
|
|
229
|
+
case TapEventID.DLCPlayableStatusChanged:
|
|
230
|
+
_dlcCallbackInstance = null;
|
|
231
|
+
break;
|
|
232
|
+
case TapEventID.GamePlayableStatusChanged:
|
|
233
|
+
_licenseCallbackInstance = null;
|
|
234
|
+
break;
|
|
235
|
+
case TapEventID.AuthorizeFinished_internal:
|
|
236
|
+
_userCallbackInternalInstance = null;
|
|
237
|
+
break;
|
|
238
|
+
case TapEventID.AuthorizeFinished:
|
|
239
|
+
_userCallbackInstance = null;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
TapSDK_UnregisterCallback((int)eventID, funcPtr);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
internal static AuthorizeResult LoginWithScopesInternal(string[] scopeStrings, string responseType, string redirectUri,
|
|
247
|
+
string codeChallenge, string state, string codeChallengeMethod, string versonCode, string sdkUa, string info)
|
|
248
|
+
{
|
|
249
|
+
try
|
|
250
|
+
{
|
|
251
|
+
TapLogger.Debug("login start ==== " + string.Join(",", scopeStrings));
|
|
252
|
+
int result = TapUser_AsyncAuthorize_internal(string.Join(",", scopeStrings), responseType, redirectUri,
|
|
253
|
+
codeChallenge, state, codeChallengeMethod, versonCode, sdkUa, info);
|
|
254
|
+
TapLogger.Debug("login end === " + result);
|
|
255
|
+
return (AuthorizeResult)result;
|
|
256
|
+
}
|
|
257
|
+
catch (Exception ex)
|
|
258
|
+
{
|
|
259
|
+
TapLogger.Debug("login crash = " + ex.StackTrace);
|
|
260
|
+
return AuthorizeResult.UNKNOWN;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
internal static AuthorizeResult LoginWithScopes(string[] scopeStrings)
|
|
265
|
+
{
|
|
266
|
+
try
|
|
267
|
+
{
|
|
268
|
+
int result = TapUser_AsyncAuthorize(string.Join(",", scopeStrings));
|
|
269
|
+
return (AuthorizeResult)result;
|
|
270
|
+
}
|
|
271
|
+
catch (Exception ex)
|
|
272
|
+
{
|
|
273
|
+
TapLogger.Debug("login crash = " + ex.Message);
|
|
274
|
+
return AuthorizeResult.UNKNOWN;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
internal static bool GetTapUserOpenId(out string openId)
|
|
279
|
+
{
|
|
280
|
+
StringBuilder openIdBuffer = new StringBuilder(256); // 分配一个足够大的缓冲区
|
|
281
|
+
bool success = TapUser_GetOpenID(openIdBuffer); // 调用 C 函数
|
|
282
|
+
openId = openIdBuffer.ToString();
|
|
283
|
+
return success;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
internal static bool GetClientId(out string clientId)
|
|
287
|
+
{
|
|
288
|
+
StringBuilder clientIDBuffer = new StringBuilder(256); // 分配一个足够大的缓冲区
|
|
289
|
+
bool success = TapSDK_GetClientID(clientIDBuffer); // 调用 C 函数
|
|
290
|
+
clientId = clientIDBuffer.ToString();
|
|
291
|
+
return success;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
internal static bool QueryDLC(string skuId)
|
|
295
|
+
{
|
|
296
|
+
return TapDLC_IsOwned(skuId);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
internal static bool ShowDLCStore(string skuId)
|
|
300
|
+
{
|
|
301
|
+
return TapDLC_ShowStore(skuId);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
internal static bool HasLicense()
|
|
305
|
+
{
|
|
306
|
+
return TapApps_IsOwned();
|
|
307
|
+
}
|
|
226
308
|
|
|
227
309
|
#endif
|
|
228
310
|
}
|
|
@@ -29,16 +29,16 @@ namespace TapSDK.Core.Standalone.Internal {
|
|
|
29
29
|
okButton.onClick.AddListener(OnOKButtonClicked);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
internal void Show(
|
|
32
|
+
internal void Show(int errorType)
|
|
33
33
|
{
|
|
34
|
-
if (errorType == TapSDKInitResult.NoPlatform){
|
|
34
|
+
if (errorType == (int)TapSDKInitResult.NoPlatform){
|
|
35
35
|
tipText.text = "获取游戏信息失败,请下载 TapTap 客户端后重新启动游戏";
|
|
36
|
-
}else if (errorType == TapSDKInitResult.NotLaunchedByPlatform){
|
|
36
|
+
}else if (errorType == (int)TapSDKInitResult.NotLaunchedByPlatform){
|
|
37
37
|
tipText.text = "获取游戏信息失败,请从 TapTap 客户端重新启动游戏";
|
|
38
|
-
}else if (errorType == TapSDKInitResult.Unknown){
|
|
38
|
+
}else if (errorType == (int)TapSDKInitResult.Unknown){
|
|
39
39
|
tipText.text = "本地发生未知错误,请从 TapTap 客户端重新启动游戏";
|
|
40
|
-
}else if (errorType == TapSDKInitResult.
|
|
41
|
-
tipText.text = "
|
|
40
|
+
}else if (errorType == (int)TapSDKInitResult.PlatformVersionMismatch){
|
|
41
|
+
tipText.text = "客户端版本不匹配,请将 TapTap 客户端升级到最新版本";
|
|
42
42
|
}else {
|
|
43
43
|
tipText.text = "发生未知错误,请从 TapTap 客户端重新启动游戏";
|
|
44
44
|
}
|
|
@@ -36,13 +36,13 @@ namespace TapSDK.Core.Standalone
|
|
|
36
36
|
if (isRuningIsLaunchedFromTapTapPC)
|
|
37
37
|
{
|
|
38
38
|
UIManager.Instance.OpenToast("IsLaunchedFromTapTapPC 正在执行,请勿重复调用", UIManager.GeneralToastLevel.Error);
|
|
39
|
-
|
|
39
|
+
Log( true,"IsLaunchedFromTapTapPC 正在执行,请勿重复调用");
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
// 多次执行时返回上一次结果
|
|
43
43
|
if (lastIsLaunchedFromTapTapPCResult != -1)
|
|
44
44
|
{
|
|
45
|
-
|
|
45
|
+
Log( false,"IsLaunchedFromTapTapPC duplicate invoke return " + lastIsLaunchedFromTapTapPCResult);
|
|
46
46
|
return lastIsLaunchedFromTapTapPCResult > 0;
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -51,7 +51,7 @@ namespace TapSDK.Core.Standalone
|
|
|
51
51
|
if (coreOptions == null)
|
|
52
52
|
{
|
|
53
53
|
UIManager.Instance.OpenToast("IsLaunchedFromTapTapPC 调用必须在初始化之后", UIManager.GeneralToastLevel.Error);
|
|
54
|
-
|
|
54
|
+
Log( true,"IsLaunchedFromTapTapPC 调用必须在初始化之后");
|
|
55
55
|
return false;
|
|
56
56
|
}
|
|
57
57
|
string clientId = coreOptions.clientId;
|
|
@@ -59,7 +59,7 @@ namespace TapSDK.Core.Standalone
|
|
|
59
59
|
if (string.IsNullOrEmpty(clientId) || string.IsNullOrEmpty(pubKey))
|
|
60
60
|
{
|
|
61
61
|
UIManager.Instance.OpenToast("clientId 及 TapPubKey 参数都不能为空, clientId =" + clientId + ", TapPubKey = " + pubKey, UIManager.GeneralToastLevel.Error);
|
|
62
|
-
|
|
62
|
+
Log( true,"clientId 或 TapPubKey 无效, clientId = " + clientId + ", TapPubKey = " + pubKey);
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
65
65
|
isRuningIsLaunchedFromTapTapPC = true;
|
|
@@ -68,27 +68,28 @@ namespace TapSDK.Core.Standalone
|
|
|
68
68
|
TapCoreTracker.Instance.TrackStart(TapCoreTracker.METHOD_LAUNCHER, sessionId);
|
|
69
69
|
try
|
|
70
70
|
{
|
|
71
|
-
TapInitResult result = await
|
|
71
|
+
TapInitResult result = await RunClientBridgeMethod(clientId, pubKey);
|
|
72
|
+
Log(false, "check startupWithClientBridge finished thread = " + Thread.CurrentThread.ManagedThreadId);
|
|
72
73
|
isRuningIsLaunchedFromTapTapPC = false;
|
|
73
74
|
if (result.needQuitGame)
|
|
74
75
|
{
|
|
75
76
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
76
77
|
TapCoreTracker.Instance.TrackSuccess(TapCoreTracker.METHOD_LAUNCHER, sessionId, TapCoreTracker.SUCCESS_TYPE_RESTART);
|
|
77
|
-
|
|
78
|
+
Log( false,"IsLaunchedFromTapTapPC Quit game");
|
|
78
79
|
Application.Quit();
|
|
79
80
|
return false;
|
|
80
81
|
}
|
|
81
82
|
else
|
|
82
83
|
{
|
|
83
|
-
if (result.result == TapSDKInitResult.OK)
|
|
84
|
+
if (result.result == (int)TapSDKInitResult.OK)
|
|
84
85
|
{
|
|
85
86
|
string currentClientId;
|
|
86
87
|
bool isFetchClientIdSuccess = TapClientBridge.GetClientId(out currentClientId);
|
|
87
|
-
|
|
88
|
+
Log( false,"IsLaunchedFromTapTapPC get clientId = " + currentClientId, false);
|
|
88
89
|
if (isFetchClientIdSuccess && !string.IsNullOrEmpty(currentClientId) && currentClientId != clientId)
|
|
89
90
|
{
|
|
90
91
|
UIManager.Instance.OpenToast("SDK 中配置的 clientId = " + clientId + "与 Tap 启动器中" + currentClientId + "不一致", UIManager.GeneralToastLevel.Error);
|
|
91
|
-
|
|
92
|
+
Log( true,"SDK 中配置的 clientId = " + clientId + "与 Tap 启动器中" + currentClientId + "不一致");
|
|
92
93
|
TapCoreTracker.Instance.TrackFailure(TapCoreTracker.METHOD_LAUNCHER, sessionId, -1, "SDK 中配置的 clientId = " + clientId + "与 Tap 启动器中" + currentClientId + "不一致");
|
|
93
94
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
94
95
|
return false;
|
|
@@ -97,17 +98,17 @@ namespace TapSDK.Core.Standalone
|
|
|
97
98
|
bool fetchOpenIdSuccess = TapClientBridge.GetTapUserOpenId(out openId);
|
|
98
99
|
if (fetchOpenIdSuccess)
|
|
99
100
|
{
|
|
100
|
-
|
|
101
|
+
Log( false,"IsLaunchedFromTapTapPC get openId = " + openId, false);
|
|
101
102
|
EventManager.TriggerEvent(EventManager.IsLaunchedFromTapTapPCFinished, openId);
|
|
102
103
|
}
|
|
103
104
|
else
|
|
104
105
|
{
|
|
105
|
-
|
|
106
|
+
Log( false,"IsLaunchedFromTapTapPC get openId failed");
|
|
106
107
|
}
|
|
107
108
|
lastIsLaunchedFromTapTapPCResult = 1;
|
|
108
109
|
TapClientBridgePoll.StartUp();
|
|
109
110
|
TapCoreTracker.Instance.TrackSuccess(TapCoreTracker.METHOD_LAUNCHER, sessionId, TapCoreTracker.SUCCESS_TYPE_INIT);
|
|
110
|
-
|
|
111
|
+
Log( false,"IsLaunchedFromTapTapPC check success");
|
|
111
112
|
return true;
|
|
112
113
|
}
|
|
113
114
|
else
|
|
@@ -115,7 +116,7 @@ namespace TapSDK.Core.Standalone
|
|
|
115
116
|
|
|
116
117
|
TapCoreTracker.Instance.TrackFailure(TapCoreTracker.METHOD_LAUNCHER, sessionId, (int)result.result, result.errorMsg ?? "");
|
|
117
118
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
118
|
-
|
|
119
|
+
Log( false,"IsLaunchedFromTapTapPC show TapClient tip Pannel " + result.result + " , error = " + result.errorMsg);
|
|
119
120
|
string tipPannelPath = "Prefabs/TapClient/TapClientConnectTipPanel";
|
|
120
121
|
if (Resources.Load<GameObject>(tipPannelPath) != null)
|
|
121
122
|
{
|
|
@@ -126,46 +127,32 @@ namespace TapSDK.Core.Standalone
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
}
|
|
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
130
|
catch (Exception e)
|
|
144
131
|
{
|
|
145
132
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
146
133
|
TapCoreTracker.Instance.TrackFailure(TapCoreTracker.METHOD_LAUNCHER, sessionId, (int)TapSDKInitResult.Unknown, e.Message ?? "");
|
|
147
134
|
|
|
148
|
-
|
|
135
|
+
Log( false,"IsLaunchedFromTapTapPC check exception = " + e.Message + " \n" + e.StackTrace);
|
|
149
136
|
string tipPannelPath = "Prefabs/TapClient/TapClientConnectTipPanel";
|
|
150
137
|
if (Resources.Load<GameObject>(tipPannelPath) != null)
|
|
151
138
|
{
|
|
152
139
|
var pannel = UIManager.Instance.OpenUI<TapClientConnectTipController>(tipPannelPath);
|
|
153
|
-
pannel.Show(TapSDKInitResult.Unknown);
|
|
140
|
+
pannel.Show((int)TapSDKInitResult.Unknown);
|
|
154
141
|
}
|
|
155
142
|
return false;
|
|
156
143
|
}
|
|
157
144
|
}
|
|
158
145
|
|
|
159
|
-
private static async Task<TapInitResult>
|
|
146
|
+
private static async Task<TapInitResult> RunClientBridgeMethod(string clientId, string pubKey)
|
|
160
147
|
{
|
|
161
148
|
TaskCompletionSource<TapInitResult> task = new TaskCompletionSource<TapInitResult>();
|
|
162
149
|
try
|
|
163
150
|
{
|
|
164
|
-
|
|
151
|
+
await Task.Run(() =>
|
|
165
152
|
{
|
|
153
|
+
Log(false, "check startupWithClientBridge start thread = " + Thread.CurrentThread.ManagedThreadId);
|
|
166
154
|
bool needQuitGame = TapClientBridge.TapSDK_RestartAppIfNecessary(clientId);
|
|
167
|
-
|
|
168
|
-
TapLogger.Debug("RunClientBridgeMethodWithTimeout invoke TapSDK_RestartAppIfNecessary finished " );
|
|
155
|
+
Log( false,"RunClientBridgeMethodWithTimeout invoke TapSDK_RestartAppIfNecessary result = " + needQuitGame);
|
|
169
156
|
if (needQuitGame)
|
|
170
157
|
{
|
|
171
158
|
tapInitResult = new TapInitResult(needQuitGame);
|
|
@@ -173,53 +160,22 @@ namespace TapSDK.Core.Standalone
|
|
|
173
160
|
else
|
|
174
161
|
{
|
|
175
162
|
string outputError;
|
|
176
|
-
|
|
177
|
-
|
|
163
|
+
int tapSDKInitResult = TapClientBridge.CheckInitState(out outputError, pubKey);
|
|
164
|
+
Log( false,"RunClientBridgeMethodWithTimeout invoke CheckInitState result = " + tapSDKInitResult + ", error = " + outputError);
|
|
178
165
|
tapInitResult = new TapInitResult(tapSDKInitResult, outputError);
|
|
179
166
|
}
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
task.TrySetResult(tapInitResult);
|
|
167
|
+
task.TrySetResult(tapInitResult);
|
|
168
|
+
});
|
|
183
169
|
|
|
184
170
|
}
|
|
185
|
-
catch (TimeoutException ex)
|
|
186
|
-
{
|
|
187
|
-
TapLogger.Debug("RunClientBridgeMethodWithTimeout invoke CheckInitState 方法执行超时!");
|
|
188
|
-
task.TrySetException(ex);
|
|
189
|
-
}
|
|
190
171
|
catch (Exception ex)
|
|
191
172
|
{
|
|
192
|
-
|
|
173
|
+
Log( false,"RunClientBridgeMethodWithTimeout invoke C 方法出错!" + ex.Message);
|
|
193
174
|
task.TrySetException(ex);
|
|
194
175
|
}
|
|
195
176
|
return await task.Task;
|
|
196
177
|
}
|
|
197
178
|
|
|
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
179
|
/// <summary>
|
|
224
180
|
/// 是否需要从启动器登录
|
|
225
181
|
/// </summary>
|
|
@@ -240,19 +196,19 @@ namespace TapSDK.Core.Standalone
|
|
|
240
196
|
if (lastIsLaunchedFromTapTapPCResult == -1)
|
|
241
197
|
{
|
|
242
198
|
// UIManager.Instance.OpenToast("IsLaunchedFromTapTapPC 正在执行,请在完成后调用授权接口", UIManager.GeneralToastLevel.Error);
|
|
243
|
-
|
|
199
|
+
Log( true," login must be invoked after IsLaunchedFromTapTapPC success");
|
|
244
200
|
throw new Exception("login must be invoked after IsLaunchedFromTapTapPC success");
|
|
245
201
|
}
|
|
246
|
-
|
|
202
|
+
Log( false,"LoginWithScopes start login by tapclient thread = " + Thread.CurrentThread.ManagedThreadId);
|
|
247
203
|
try
|
|
248
204
|
{
|
|
249
|
-
TapClientBridge.RegisterCallback(TapEventID.
|
|
250
|
-
AuthorizeResult authorizeResult = TapClientBridge.
|
|
205
|
+
TapClientBridge.RegisterCallback(TapEventID.AuthorizeFinished_internal, loginCallbackDelegate);
|
|
206
|
+
AuthorizeResult authorizeResult = TapClientBridge.LoginWithScopesInternal(scopes, responseType, redirectUri,
|
|
251
207
|
codeChallenge, state, codeChallengeMethod, versonCode, sdkUa, info);
|
|
252
|
-
|
|
208
|
+
Log( false,"LoginWithScopes start result = " + authorizeResult);
|
|
253
209
|
if (authorizeResult != AuthorizeResult.OK)
|
|
254
210
|
{
|
|
255
|
-
TapClientBridge.UnRegisterCallback(TapEventID.
|
|
211
|
+
TapClientBridge.UnRegisterCallback(TapEventID.AuthorizeFinished_internal,loginCallbackDelegate);
|
|
256
212
|
return false;
|
|
257
213
|
}
|
|
258
214
|
else
|
|
@@ -264,8 +220,8 @@ namespace TapSDK.Core.Standalone
|
|
|
264
220
|
}
|
|
265
221
|
catch (Exception ex)
|
|
266
222
|
{
|
|
267
|
-
|
|
268
|
-
TapClientBridge.UnRegisterCallback(TapEventID.
|
|
223
|
+
Log( false,"LoginWithScopes start login by tapclient error = " + ex.Message);
|
|
224
|
+
TapClientBridge.UnRegisterCallback(TapEventID.AuthorizeFinished_internal,loginCallbackDelegate);
|
|
269
225
|
return false;
|
|
270
226
|
}
|
|
271
227
|
|
|
@@ -275,30 +231,139 @@ namespace TapSDK.Core.Standalone
|
|
|
275
231
|
[AOT.MonoPInvokeCallback(typeof(TapClientBridge.CallbackDelegate))]
|
|
276
232
|
static void loginCallbackDelegate(int id, IntPtr userData)
|
|
277
233
|
{
|
|
278
|
-
|
|
279
|
-
if (id == (int)TapEventID.
|
|
234
|
+
Log( false,"LoginWithScopes recevie callback " + id);
|
|
235
|
+
if (id == (int)TapEventID.AuthorizeFinished_internal)
|
|
280
236
|
{
|
|
281
|
-
|
|
237
|
+
Log( false,"LoginWithScopes callback thread = " + Thread.CurrentThread.ManagedThreadId);
|
|
282
238
|
TapClientBridge.AuthorizeFinishedResponse response = Marshal.PtrToStructure<TapClientBridge.AuthorizeFinishedResponse>(userData);
|
|
283
|
-
|
|
239
|
+
Log( false,"LoginWithScopes callback = " + response.is_cancel + " uri = " + response.callback_uri);
|
|
284
240
|
if (currentLoginCallback != null)
|
|
285
241
|
{
|
|
286
242
|
currentLoginCallback(response.is_cancel != 0, response.callback_uri);
|
|
287
|
-
TapClientBridge.UnRegisterCallback(TapEventID.
|
|
243
|
+
TapClientBridge.UnRegisterCallback(TapEventID.AuthorizeFinished_internal,loginCallbackDelegate);
|
|
288
244
|
currentLoginCallback = null;
|
|
289
245
|
}
|
|
290
246
|
}
|
|
291
247
|
}
|
|
248
|
+
|
|
249
|
+
// DLC 相关功能
|
|
250
|
+
private static Action<string, bool> currentDlcDelegate;
|
|
251
|
+
private static Action<bool> currentLicenseDelegate;
|
|
252
|
+
|
|
253
|
+
/// 查询是否购买 DLC , 未调用 isLaunchFromPC 会抛异常
|
|
254
|
+
public static bool QueryDLC(string skuId)
|
|
255
|
+
{
|
|
256
|
+
if (lastIsLaunchedFromTapTapPCResult != 1)
|
|
257
|
+
{
|
|
258
|
+
throw new Exception("queryDLC must be invoked after IsLaunchedFromTapTapPC success");
|
|
259
|
+
}
|
|
260
|
+
bool success = TapClientBridge.QueryDLC(skuId);
|
|
261
|
+
return success;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/// 跳转到 TapTap 客户端 DLC 购买页面 , 未调用 isLaunchFromPC 会抛异常
|
|
265
|
+
public static bool ShowStore(string skuId)
|
|
266
|
+
{
|
|
267
|
+
if (lastIsLaunchedFromTapTapPCResult != 1)
|
|
268
|
+
{
|
|
269
|
+
throw new Exception("purchaseDLC must be invoked after IsLaunchedFromTapTapPC success");
|
|
270
|
+
}
|
|
271
|
+
Log(false, "purchaseDLC start = " + skuId);
|
|
272
|
+
return TapClientBridge.TapDLC_ShowStore(skuId);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/// 注册 DLC 购买状态变更回调,包括购买成功和退款
|
|
276
|
+
public static void RegisterDLCOwnedCallback(Action<string, bool> dlcDelegate)
|
|
277
|
+
{
|
|
278
|
+
currentDlcDelegate = dlcDelegate;
|
|
279
|
+
TapClientBridge.RegisterCallback(TapEventID.DLCPlayableStatusChanged, DLCCallbackDelegate);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/// DLC 回调
|
|
283
|
+
[AOT.MonoPInvokeCallback(typeof(TapClientBridge.CallbackDelegate))]
|
|
284
|
+
static void DLCCallbackDelegate(int id, IntPtr userData)
|
|
285
|
+
{
|
|
286
|
+
Log(false, "queryDlC recevie callback " + id);
|
|
287
|
+
if (currentDlcDelegate != null)
|
|
288
|
+
{
|
|
289
|
+
TapClientBridge.DLCPlayableStatusChangedResponse response = Marshal.PtrToStructure<TapClientBridge.DLCPlayableStatusChangedResponse>(userData);
|
|
290
|
+
Log(false, "queryDlC callback = " + response.dlc_id + " isOwn = " + response.is_playable);
|
|
291
|
+
currentDlcDelegate(response.dlc_id, response.is_playable != 0);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/// 注册 License 购买状态变更回调,包括购买成功和退款
|
|
296
|
+
public static void RegisterLicenseCallback(Action<bool> licensecDelegate)
|
|
297
|
+
{
|
|
298
|
+
currentLicenseDelegate = licensecDelegate;
|
|
299
|
+
TapClientBridge.RegisterCallback(TapEventID.GamePlayableStatusChanged, LicenseCallbackDelegate);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/// License 回调
|
|
303
|
+
[AOT.MonoPInvokeCallback(typeof(TapClientBridge.CallbackDelegate))]
|
|
304
|
+
static void LicenseCallbackDelegate(int id, IntPtr userData)
|
|
305
|
+
{
|
|
306
|
+
Log(false, "License recevie callback " + id);
|
|
307
|
+
if (currentLicenseDelegate != null)
|
|
308
|
+
{
|
|
309
|
+
TapClientBridge.GamePlayableStatusChangedResponse response = Marshal.PtrToStructure<TapClientBridge.GamePlayableStatusChangedResponse>(userData);
|
|
310
|
+
Log(false, "License callback isOwn changed " + response.is_playable );
|
|
311
|
+
currentLicenseDelegate(response.is_playable != 0);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
public static bool HasLicense()
|
|
316
|
+
{
|
|
317
|
+
if (lastIsLaunchedFromTapTapPCResult != 1)
|
|
318
|
+
{
|
|
319
|
+
throw new Exception("checkLicense must be invoked after IsLaunchedFromTapTapPC success");
|
|
320
|
+
}
|
|
321
|
+
return TapClientBridge.HasLicense();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
private static void Log(bool isError, string data, bool alwaysShow = true)
|
|
326
|
+
{
|
|
327
|
+
if (!string.IsNullOrEmpty(data))
|
|
328
|
+
{
|
|
329
|
+
if (TapLogger.LogDelegate != null)
|
|
330
|
+
{
|
|
331
|
+
if (isError)
|
|
332
|
+
{
|
|
333
|
+
TapLogger.Error(data);
|
|
334
|
+
}
|
|
335
|
+
else
|
|
336
|
+
{
|
|
337
|
+
TapLogger.Debug(data);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
}
|
|
341
|
+
else
|
|
342
|
+
{
|
|
343
|
+
if (alwaysShow || TapTapSDK.taptapSdkOptions.enableLog)
|
|
344
|
+
{
|
|
345
|
+
if (isError)
|
|
346
|
+
{
|
|
347
|
+
UnityEngine.Debug.LogErrorFormat($"[TapSDK] ERROR: {data}");
|
|
348
|
+
}
|
|
349
|
+
else
|
|
350
|
+
{
|
|
351
|
+
UnityEngine.Debug.LogFormat($"[TapSDK] INFO: {data}");
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
292
357
|
|
|
293
358
|
// 初始化校验结果
|
|
294
359
|
private class TapInitResult
|
|
295
360
|
{
|
|
296
|
-
internal
|
|
361
|
+
internal int result;
|
|
297
362
|
internal string errorMsg;
|
|
298
363
|
|
|
299
364
|
internal bool needQuitGame = false;
|
|
300
365
|
|
|
301
|
-
public TapInitResult(
|
|
366
|
+
public TapInitResult(int result, string errorMsg)
|
|
302
367
|
{
|
|
303
368
|
this.result = result;
|
|
304
369
|
this.errorMsg = errorMsg;
|
package/link.xml
ADDED
package/link.xml.meta
ADDED