com.taptap.sdk.leaderboard 4.8.1 → 4.8.2
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/BuidPostProcessor.cs +60 -0
- package/Mobile/Editor/BuidPostProcessor.cs.meta +11 -0
- package/Mobile/Editor/NativeDependencies.xml +7 -1
- package/Mobile/Runtime/TapTapLeaderboardImpl.cs +224 -149
- package/Runtime/Internal/TapTapLeaderboardManager.cs +14 -15
- package/Runtime/Public/ILeaderboardPlatform.cs +12 -15
- package/Runtime/Public/TapTapLeaderboard.cs +19 -26
- package/package.json +3 -3
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
using UnityEditor.Callbacks;
|
|
4
|
+
# if UNITY_IOS
|
|
5
|
+
using UnityEditor.iOS.Xcode;
|
|
6
|
+
#endif
|
|
7
|
+
using System.IO;
|
|
8
|
+
using System.Collections.Generic;
|
|
9
|
+
using System.Linq;
|
|
10
|
+
using TapSDK.Core.Editor;
|
|
11
|
+
using System.Diagnostics;
|
|
12
|
+
|
|
13
|
+
#if UNITY_IOS
|
|
14
|
+
public class BuildPostProcessor
|
|
15
|
+
{
|
|
16
|
+
[PostProcessBuild(999)]
|
|
17
|
+
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
|
|
18
|
+
{
|
|
19
|
+
if (buildTarget == BuildTarget.iOS)
|
|
20
|
+
{
|
|
21
|
+
var projPath = TapSDKCoreCompile.GetProjPath(path);
|
|
22
|
+
var proj = TapSDKCoreCompile.ParseProjPath(projPath);
|
|
23
|
+
var target = TapSDKCoreCompile.GetUnityTarget(proj);
|
|
24
|
+
|
|
25
|
+
if (TapSDKCoreCompile.CheckTarget(target))
|
|
26
|
+
{
|
|
27
|
+
UnityEngine.Debug.LogError("Unity-iPhone is NUll");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (TapSDKCoreCompile.HandlerIOSSetting(path,
|
|
31
|
+
Application.dataPath,
|
|
32
|
+
"TapTapLeaderboardResource",
|
|
33
|
+
"com.taptap.sdk.leaderboard",
|
|
34
|
+
"Leaderboard",
|
|
35
|
+
new[] { "TapTapLeaderboardResource.bundle" },
|
|
36
|
+
target, projPath, proj,
|
|
37
|
+
"TapTapLeaderboardSDK"))
|
|
38
|
+
{
|
|
39
|
+
UnityEngine.Debug.Log("TapLeaderboard add Bundle Success!");
|
|
40
|
+
}
|
|
41
|
+
if (TapSDKCoreCompile.HandlerIOSSetting(path,
|
|
42
|
+
Application.dataPath,
|
|
43
|
+
"TapTapProfileResource",
|
|
44
|
+
"com.taptap.sdk.profile",
|
|
45
|
+
"Profile",
|
|
46
|
+
new[] { "TapTapProfileResource.bundle" },
|
|
47
|
+
target, projPath, proj,
|
|
48
|
+
"TapTapProfileSDK"))
|
|
49
|
+
{
|
|
50
|
+
UnityEngine.Debug.Log("TapProfile add Bundle Success!");
|
|
51
|
+
TapSDKCoreCompile.ExecutePodCommand("pod deintegrate && pod install", path);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
UnityEngine.Debug.LogWarning("TapLeaderboard add Bundle Failed!");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
#endif
|
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
<repositories>
|
|
5
5
|
<repository>https://repo.maven.apache.org/maven2</repository>
|
|
6
6
|
</repositories>
|
|
7
|
-
<androidPackage spec="com.taptap.sdk:tap-leaderboard-unity:4.8.
|
|
7
|
+
<androidPackage spec="com.taptap.sdk:tap-leaderboard-unity:4.8.2"/>
|
|
8
8
|
</androidPackages>
|
|
9
|
+
<iosPods>
|
|
10
|
+
<sources>
|
|
11
|
+
<source>https://github.com/CocoaPods/Specs.git</source>
|
|
12
|
+
</sources>
|
|
13
|
+
<iosPod addToAllTargets="false" bitcodeEnabled="false" name="TapTapLeaderboardSDK" version="4.8.2"/>
|
|
14
|
+
</iosPods>
|
|
9
15
|
</dependencies>
|
|
@@ -48,9 +48,10 @@ namespace TapSDK.Leaderboard.Mobile
|
|
|
48
48
|
EngineBridge.GetInstance().CallHandler(command);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
public
|
|
52
|
-
ITapTapLeaderboardResponseCallback<SubmitScoresResponse> callback)
|
|
51
|
+
public Task<SubmitScoresResponse> SubmitScores(List<SubmitScoresRequest.ScoreItem> scores)
|
|
53
52
|
{
|
|
53
|
+
TapLog.Log("[TapTapLeaderboardImpl] SubmitScores called with Task<SubmitScoresResponse> return type (NEW API)");
|
|
54
|
+
var taskSource = new TaskCompletionSource<SubmitScoresResponse>();
|
|
54
55
|
var command = new Command.Builder()
|
|
55
56
|
.Service(SERVICE_NAME)
|
|
56
57
|
.Method("submitScores")
|
|
@@ -60,50 +61,59 @@ namespace TapSDK.Leaderboard.Mobile
|
|
|
60
61
|
.CommandBuilder();
|
|
61
62
|
EngineBridge.GetInstance().CallHandler(command, result =>
|
|
62
63
|
{
|
|
63
|
-
|
|
64
|
+
try
|
|
64
65
|
{
|
|
65
|
-
|
|
66
|
+
if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
|
|
67
|
+
{
|
|
68
|
+
taskSource.TrySetException(new TapException(-1, "Failed to submit scores: code=" + result.code + " content=" + result.content));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
TapLog.Log("SubmitScores, result ==>>> " + JsonConvert.SerializeObject(result));
|
|
73
|
+
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
|
74
|
+
var status = SafeDictionary.GetValue<string>(dic, "status");
|
|
75
|
+
switch (status)
|
|
76
|
+
{
|
|
77
|
+
case "success":
|
|
78
|
+
var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
|
|
79
|
+
TapLog.Log("submit scores success: " + jsonStr);
|
|
80
|
+
var data = JsonConvert.DeserializeObject<SubmitScoresResponse>(jsonStr);
|
|
81
|
+
if (data != null)
|
|
82
|
+
{
|
|
83
|
+
taskSource.TrySetResult(data);
|
|
84
|
+
}
|
|
85
|
+
else
|
|
86
|
+
{
|
|
87
|
+
taskSource.TrySetException(new TapException(-1, "json convert failed: content=" + jsonStr));
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case "failure":
|
|
91
|
+
var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
|
|
92
|
+
var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
|
|
93
|
+
TapLog.Log("failed to submit scores, errorCode: " + errorCode + ", errorMsg: " + errorMsg);
|
|
94
|
+
taskSource.TrySetException(new TapException(errorCode, errorMsg));
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
taskSource.TrySetException(new TapException(-1, "Unknown status: " + status));
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
66
100
|
}
|
|
67
|
-
|
|
68
|
-
if (string.IsNullOrEmpty(result.content))
|
|
101
|
+
catch (Exception e)
|
|
69
102
|
{
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
TapLog.Log("SubmitScores, result ==>>> " + JsonConvert.SerializeObject(result));
|
|
74
|
-
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
|
75
|
-
var status = SafeDictionary.GetValue<string>(dic, "status");
|
|
76
|
-
switch (status)
|
|
77
|
-
{
|
|
78
|
-
case "success":
|
|
79
|
-
var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
|
|
80
|
-
TapLog.Log("submit scores success: " + jsonStr);
|
|
81
|
-
var data = JsonConvert.DeserializeObject<SubmitScoresResponse>(jsonStr);
|
|
82
|
-
if (callback != null)
|
|
83
|
-
{
|
|
84
|
-
callback.OnSuccess(data);
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
case "failure":
|
|
88
|
-
var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
|
|
89
|
-
var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
|
|
90
|
-
TapLog.Log("failed to submit scores, errorCode: " + errorCode + ", errorMsg: " + errorMsg);
|
|
91
|
-
if (callback != null)
|
|
92
|
-
{
|
|
93
|
-
callback.OnFailure(errorCode, errorMsg);
|
|
94
|
-
}
|
|
95
|
-
break;
|
|
103
|
+
taskSource.TrySetException(new TapException(-1, "Failed to submit scores: error=" + e.Message + ", content=" + result.content));
|
|
96
104
|
}
|
|
97
105
|
});
|
|
106
|
+
return taskSource.Task;
|
|
98
107
|
}
|
|
99
108
|
|
|
100
|
-
public
|
|
109
|
+
public Task<LeaderboardScoreResponse> LoadLeaderboardScores(
|
|
101
110
|
string leaderboardId,
|
|
102
111
|
string leaderboardCollection,
|
|
103
112
|
string nextPage,
|
|
104
|
-
string periodToken
|
|
105
|
-
ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback)
|
|
113
|
+
string periodToken)
|
|
106
114
|
{
|
|
115
|
+
TapLog.Log("[TapTapLeaderboardImpl] LoadLeaderboardScores called with Task<LeaderboardScoreResponse> return type (NEW API)");
|
|
116
|
+
var taskSource = new TaskCompletionSource<LeaderboardScoreResponse>();
|
|
107
117
|
var command = new Command.Builder()
|
|
108
118
|
.Service(SERVICE_NAME)
|
|
109
119
|
.Method("loadLeaderboardScores")
|
|
@@ -111,106 +121,128 @@ namespace TapSDK.Leaderboard.Mobile
|
|
|
111
121
|
.Args("leaderboardCollection", leaderboardCollection)
|
|
112
122
|
.Args("nextPage", nextPage)
|
|
113
123
|
.Args("periodToken", periodToken)
|
|
124
|
+
.Callback(true)
|
|
125
|
+
.OnceTime(true)
|
|
114
126
|
.CommandBuilder();
|
|
115
127
|
|
|
116
128
|
EngineBridge.GetInstance().CallHandler(command, result =>
|
|
117
129
|
{
|
|
118
|
-
|
|
130
|
+
try
|
|
119
131
|
{
|
|
120
|
-
|
|
132
|
+
if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
|
|
133
|
+
{
|
|
134
|
+
taskSource.TrySetException(new TapException(-1, "Failed to load leaderboard scores: code=" + result.code + " content=" + result.content));
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
TapLog.Log("LoadLeaderboardScores, result ==>>> " + JsonConvert.SerializeObject(result));
|
|
139
|
+
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
|
140
|
+
var status = SafeDictionary.GetValue<string>(dic, "status");
|
|
141
|
+
switch (status)
|
|
142
|
+
{
|
|
143
|
+
case "success":
|
|
144
|
+
var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
|
|
145
|
+
TapLog.Log("load leaderboard scores success: " + jsonStr);
|
|
146
|
+
var data = JsonConvert.DeserializeObject<LeaderboardScoreResponse>(jsonStr);
|
|
147
|
+
if (data != null)
|
|
148
|
+
{
|
|
149
|
+
taskSource.TrySetResult(data);
|
|
150
|
+
}
|
|
151
|
+
else
|
|
152
|
+
{
|
|
153
|
+
taskSource.TrySetException(new TapException(-1, "json convert failed: content=" + jsonStr));
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
case "failure":
|
|
157
|
+
var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
|
|
158
|
+
var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
|
|
159
|
+
TapLog.Log("load leaderboard scores failed, errorCode: " + errorCode + ", errorMsg: " + errorMsg);
|
|
160
|
+
taskSource.TrySetException(new TapException(errorCode, errorMsg));
|
|
161
|
+
break;
|
|
162
|
+
default:
|
|
163
|
+
taskSource.TrySetException(new TapException(-1, "Unknown status: " + status));
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
121
166
|
}
|
|
122
|
-
|
|
123
|
-
if (string.IsNullOrEmpty(result.content))
|
|
167
|
+
catch (Exception e)
|
|
124
168
|
{
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
TapLog.Log("LoadLeaderboardScores, result ==>>> " + JsonConvert.SerializeObject(result));
|
|
129
|
-
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
|
130
|
-
var status = SafeDictionary.GetValue<string>(dic, "status");
|
|
131
|
-
switch (status)
|
|
132
|
-
{
|
|
133
|
-
case "success":
|
|
134
|
-
var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
|
|
135
|
-
TapLog.Log("load leaderboard scores success: " + jsonStr);
|
|
136
|
-
var data = JsonConvert.DeserializeObject<LeaderboardScoreResponse>(jsonStr);
|
|
137
|
-
if (callback != null)
|
|
138
|
-
{
|
|
139
|
-
callback.OnSuccess(data);
|
|
140
|
-
}
|
|
141
|
-
break;
|
|
142
|
-
case "failure":
|
|
143
|
-
var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
|
|
144
|
-
var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
|
|
145
|
-
TapLog.Log("load leaderboard scores failed, errorCode: " + errorCode + ", errorMsg: " + errorMsg);
|
|
146
|
-
if (callback != null)
|
|
147
|
-
{
|
|
148
|
-
callback.OnFailure(errorCode, errorMsg);
|
|
149
|
-
}
|
|
150
|
-
break;
|
|
169
|
+
taskSource.TrySetException(new TapException(-1, "Failed to load leaderboard scores: error=" + e.Message + ", content=" + result.content));
|
|
151
170
|
}
|
|
152
171
|
});
|
|
172
|
+
return taskSource.Task;
|
|
153
173
|
}
|
|
154
174
|
|
|
155
|
-
public
|
|
175
|
+
public Task<UserScoreResponse> LoadCurrentPlayerLeaderboardScore(
|
|
156
176
|
string leaderboardId,
|
|
157
177
|
string leaderboardCollection,
|
|
158
|
-
string periodToken
|
|
159
|
-
ITapTapLeaderboardResponseCallback<UserScoreResponse> callback)
|
|
178
|
+
string periodToken)
|
|
160
179
|
{
|
|
180
|
+
TapLog.Log("[TapTapLeaderboardImpl] LoadCurrentPlayerLeaderboardScore called with Task<UserScoreResponse> return type (NEW API)");
|
|
181
|
+
var taskSource = new TaskCompletionSource<UserScoreResponse>();
|
|
161
182
|
var command = new Command.Builder()
|
|
162
183
|
.Service(SERVICE_NAME)
|
|
163
184
|
.Method("loadCurrentPlayerLeaderboardScore")
|
|
164
185
|
.Args("leaderboardId", leaderboardId)
|
|
165
186
|
.Args("leaderboardCollection", leaderboardCollection)
|
|
166
187
|
.Args("periodToken", periodToken)
|
|
188
|
+
.Callback(true)
|
|
189
|
+
.OnceTime(true)
|
|
167
190
|
.CommandBuilder();
|
|
168
191
|
EngineBridge.GetInstance().CallHandler(command, result =>
|
|
169
192
|
{
|
|
170
|
-
|
|
171
|
-
{
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (string.IsNullOrEmpty(result.content))
|
|
193
|
+
try
|
|
176
194
|
{
|
|
177
|
-
|
|
195
|
+
if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
|
|
196
|
+
{
|
|
197
|
+
taskSource.TrySetException(new TapException(-1, "Failed to load current player leaderboard score: code=" + result.code + " content=" + result.content));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
TapLog.Log("LoadCurrentPlayerLeaderboardScore, result ==>>> " + JsonConvert.SerializeObject(result));
|
|
202
|
+
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
|
203
|
+
var status = SafeDictionary.GetValue<string>(dic, "status");
|
|
204
|
+
switch (status)
|
|
205
|
+
{
|
|
206
|
+
case "success":
|
|
207
|
+
var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
|
|
208
|
+
TapLog.Log("Load current player leaderboard score success: " + jsonStr);
|
|
209
|
+
var data = JsonConvert.DeserializeObject<UserScoreResponse>(jsonStr);
|
|
210
|
+
if (data != null)
|
|
211
|
+
{
|
|
212
|
+
taskSource.TrySetResult(data);
|
|
213
|
+
}
|
|
214
|
+
else
|
|
215
|
+
{
|
|
216
|
+
taskSource.TrySetException(new TapException(-1, "json convert failed: content=" + jsonStr));
|
|
217
|
+
}
|
|
218
|
+
break;
|
|
219
|
+
case "failure":
|
|
220
|
+
var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
|
|
221
|
+
var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
|
|
222
|
+
TapLog.Log("Load current player leaderboard score failed: errorCode: " + errorCode + ", errorMsg: " + errorMsg);
|
|
223
|
+
taskSource.TrySetException(new TapException(errorCode, errorMsg));
|
|
224
|
+
break;
|
|
225
|
+
default:
|
|
226
|
+
taskSource.TrySetException(new TapException(-1, "Unknown status: " + status));
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
178
229
|
}
|
|
179
|
-
|
|
180
|
-
TapLog.Log("LoadCurrentPlayerLeaderboardScore, result ==>>> " + JsonConvert.SerializeObject(result));
|
|
181
|
-
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
|
182
|
-
var status = SafeDictionary.GetValue<string>(dic, "status");
|
|
183
|
-
switch (status)
|
|
230
|
+
catch (Exception e)
|
|
184
231
|
{
|
|
185
|
-
|
|
186
|
-
var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
|
|
187
|
-
TapLog.Log("Load current player leaderboard score success: " + jsonStr);
|
|
188
|
-
var data = JsonConvert.DeserializeObject<UserScoreResponse>(jsonStr);
|
|
189
|
-
if (callback != null)
|
|
190
|
-
{
|
|
191
|
-
callback.OnSuccess(data);
|
|
192
|
-
}
|
|
193
|
-
break;
|
|
194
|
-
case "failure":
|
|
195
|
-
var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
|
|
196
|
-
var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
|
|
197
|
-
TapLog.Log("Load current player leaderboard score failed: errorCode: " + errorCode + ", errorMsg: " + errorMsg);
|
|
198
|
-
if (callback != null)
|
|
199
|
-
{
|
|
200
|
-
callback.OnFailure(errorCode, errorMsg);
|
|
201
|
-
}
|
|
202
|
-
break;
|
|
232
|
+
taskSource.TrySetException(new TapException(-1, "Failed to load current player leaderboard score: error=" + e.Message + ", content=" + result.content));
|
|
203
233
|
}
|
|
204
234
|
});
|
|
235
|
+
return taskSource.Task;
|
|
205
236
|
}
|
|
206
237
|
|
|
207
|
-
public
|
|
238
|
+
public Task<LeaderboardScoreResponse> LoadPlayerCenteredScores(
|
|
208
239
|
string leaderboardId,
|
|
209
240
|
string leaderboardCollection,
|
|
210
241
|
string periodToken,
|
|
211
|
-
int? maxCount
|
|
212
|
-
ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback)
|
|
242
|
+
int? maxCount)
|
|
213
243
|
{
|
|
244
|
+
TapLog.Log("[TapTapLeaderboardImpl] LoadPlayerCenteredScores called with Task<LeaderboardScoreResponse> return type (NEW API)");
|
|
245
|
+
var taskSource = new TaskCompletionSource<LeaderboardScoreResponse>();
|
|
214
246
|
var command = new Command.Builder()
|
|
215
247
|
.Service(SERVICE_NAME)
|
|
216
248
|
.Method("loadPlayerCenteredScores")
|
|
@@ -218,44 +250,54 @@ namespace TapSDK.Leaderboard.Mobile
|
|
|
218
250
|
.Args("leaderboardCollection", leaderboardCollection)
|
|
219
251
|
.Args("periodToken", periodToken)
|
|
220
252
|
.Args("maxCount", maxCount)
|
|
253
|
+
.Callback(true)
|
|
254
|
+
.OnceTime(true)
|
|
221
255
|
.CommandBuilder();
|
|
222
256
|
EngineBridge.GetInstance().CallHandler(command, result =>
|
|
223
257
|
{
|
|
224
|
-
|
|
258
|
+
try
|
|
225
259
|
{
|
|
226
|
-
|
|
260
|
+
if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
|
|
261
|
+
{
|
|
262
|
+
taskSource.TrySetException(new TapException(-1, "Failed to load player centered scores: code=" + result.code + " content=" + result.content));
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
TapLog.Log("LoadPlayerCenteredScores, result ==>>> " + JsonConvert.SerializeObject(result));
|
|
267
|
+
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
|
268
|
+
var status = SafeDictionary.GetValue<string>(dic, "status");
|
|
269
|
+
switch (status)
|
|
270
|
+
{
|
|
271
|
+
case "success":
|
|
272
|
+
var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
|
|
273
|
+
TapLog.Log("Load player centered scores success: " + jsonStr);
|
|
274
|
+
var data = JsonConvert.DeserializeObject<LeaderboardScoreResponse>(jsonStr);
|
|
275
|
+
if (data != null)
|
|
276
|
+
{
|
|
277
|
+
taskSource.TrySetResult(data);
|
|
278
|
+
}
|
|
279
|
+
else
|
|
280
|
+
{
|
|
281
|
+
taskSource.TrySetException(new TapException(-1, "json convert failed: content=" + jsonStr));
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
case "failure":
|
|
285
|
+
var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
|
|
286
|
+
var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
|
|
287
|
+
TapLog.Log("Load failed load player centered scores:: errorCode: " + errorCode + ", errorMsg: " + errorMsg);
|
|
288
|
+
taskSource.TrySetException(new TapException(errorCode, errorMsg));
|
|
289
|
+
break;
|
|
290
|
+
default:
|
|
291
|
+
taskSource.TrySetException(new TapException(-1, "Unknown status: " + status));
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
227
294
|
}
|
|
228
|
-
|
|
229
|
-
if (string.IsNullOrEmpty(result.content))
|
|
295
|
+
catch (Exception e)
|
|
230
296
|
{
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
TapLog.Log("LoadPlayerCenteredScores, result ==>>> " + JsonConvert.SerializeObject(result));
|
|
235
|
-
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
|
236
|
-
var status = SafeDictionary.GetValue<string>(dic, "status");
|
|
237
|
-
switch (status)
|
|
238
|
-
{
|
|
239
|
-
case "success":
|
|
240
|
-
var jsonStr = SafeDictionary.GetValue<string>(dic, "data");
|
|
241
|
-
TapLog.Log("Load player centered scores success: " + jsonStr);
|
|
242
|
-
var data = JsonConvert.DeserializeObject<LeaderboardScoreResponse>(jsonStr);
|
|
243
|
-
if (callback != null)
|
|
244
|
-
{
|
|
245
|
-
callback.OnSuccess(data);
|
|
246
|
-
}
|
|
247
|
-
break;
|
|
248
|
-
case "failure":
|
|
249
|
-
var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
|
|
250
|
-
var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
|
|
251
|
-
TapLog.Log("Load failed load player centered scores:: errorCode: " + errorCode + ", errorMsg: " + errorMsg);
|
|
252
|
-
if (callback != null)
|
|
253
|
-
{
|
|
254
|
-
callback.OnFailure(errorCode, errorMsg);
|
|
255
|
-
}
|
|
256
|
-
break;
|
|
297
|
+
taskSource.TrySetException(new TapException(-1, "Failed to load player centered scores: error=" + e.Message + ", content=" + result.content));
|
|
257
298
|
}
|
|
258
299
|
});
|
|
300
|
+
return taskSource.Task;
|
|
259
301
|
}
|
|
260
302
|
|
|
261
303
|
public void SetShareCallback(ITapTapLeaderboardShareCallback callback)
|
|
@@ -323,28 +365,61 @@ namespace TapSDK.Leaderboard.Mobile
|
|
|
323
365
|
.CommandBuilder();
|
|
324
366
|
EngineBridge.GetInstance().CallHandler(command, (result) =>
|
|
325
367
|
{
|
|
326
|
-
|
|
368
|
+
try
|
|
327
369
|
{
|
|
328
|
-
|
|
329
|
-
|
|
370
|
+
if (result.code != Result.RESULT_SUCCESS)
|
|
371
|
+
{
|
|
372
|
+
TapLog.Log("InitRegisterCallBack failed with code: " + result.code);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
330
375
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
376
|
+
if (string.IsNullOrEmpty(result.content))
|
|
377
|
+
{
|
|
378
|
+
TapLog.Log("InitRegisterCallBack result content is empty");
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
TapLog.Log("InitRegisterCallBack result content: " + result.content);
|
|
383
|
+
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
|
384
|
+
var status = SafeDictionary.GetValue<string>(dic, "status");
|
|
385
|
+
switch (status)
|
|
386
|
+
{
|
|
387
|
+
case "success":
|
|
388
|
+
// Fix: data is already an object, not a string that needs deserialization
|
|
389
|
+
var dataDic = SafeDictionary.GetValue<Dictionary<string, object>>(dic, "data");
|
|
390
|
+
if (dataDic != null)
|
|
391
|
+
{
|
|
392
|
+
var code = SafeDictionary.GetValue<int>(dataDic, "code");
|
|
393
|
+
var message = SafeDictionary.GetValue<string>(dataDic, "message");
|
|
394
|
+
TapLog.Log("InitRegisterCallBack callback result - code: " + code + ", message: " + message);
|
|
395
|
+
foreach (var callback in callbacks)
|
|
396
|
+
{
|
|
397
|
+
callback.OnLeaderboardResult(code, message);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
else
|
|
401
|
+
{
|
|
402
|
+
TapLog.Log("InitRegisterCallBack data field is null or invalid");
|
|
403
|
+
}
|
|
404
|
+
break;
|
|
405
|
+
|
|
406
|
+
case "failure":
|
|
407
|
+
var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
|
|
408
|
+
var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
|
|
409
|
+
TapLog.Log("InitRegisterCallBack failed - errorCode: " + errorCode + ", errorMsg: " + errorMsg);
|
|
410
|
+
foreach (var callback in callbacks)
|
|
411
|
+
{
|
|
412
|
+
callback.OnLeaderboardResult(errorCode, errorMsg);
|
|
413
|
+
}
|
|
414
|
+
break;
|
|
415
|
+
default:
|
|
416
|
+
TapLog.Log("InitRegisterCallBack unknown status: " + status);
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
334
419
|
}
|
|
335
|
-
|
|
336
|
-
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
|
|
337
|
-
var status = SafeDictionary.GetValue<string>(dic, "status");
|
|
338
|
-
switch (status)
|
|
420
|
+
catch (Exception e)
|
|
339
421
|
{
|
|
340
|
-
|
|
341
|
-
var errorCode = SafeDictionary.GetValue<int>(dic, "errCode");
|
|
342
|
-
var errorMsg = SafeDictionary.GetValue<string>(dic, "errMessage");
|
|
343
|
-
foreach (var callback in callbacks)
|
|
344
|
-
{
|
|
345
|
-
callback.OnLeaderboardResult(errorCode, errorMsg);
|
|
346
|
-
}
|
|
347
|
-
break;
|
|
422
|
+
TapLog.Log("InitRegisterCallBack exception: " + e.Message + ", content: " + result.content);
|
|
348
423
|
}
|
|
349
424
|
});
|
|
350
425
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
using System.Collections.Generic;
|
|
2
|
+
using System.Threading.Tasks;
|
|
2
3
|
using TapSDK.Core.Internal.Utils;
|
|
3
4
|
|
|
4
5
|
namespace TapSDK.Leaderboard.Runtime.Internal
|
|
@@ -24,35 +25,33 @@ namespace TapSDK.Leaderboard.Runtime.Internal
|
|
|
24
25
|
public void OpenLeaderboard(string leaderboardId, string collection) =>
|
|
25
26
|
_platform.OpenLeaderboard(leaderboardId, collection);
|
|
26
27
|
|
|
27
|
-
public
|
|
28
|
-
ITapTapLeaderboardResponseCallback<SubmitScoresResponse> callback)
|
|
28
|
+
public Task<SubmitScoresResponse> SubmitScores(List<SubmitScoresRequest.ScoreItem> scores)
|
|
29
29
|
{
|
|
30
|
-
_platform.SubmitScores(scores
|
|
30
|
+
return _platform.SubmitScores(scores);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
public
|
|
33
|
+
public Task<LeaderboardScoreResponse> LoadLeaderboardScores(
|
|
34
34
|
string leaderboardId,
|
|
35
35
|
string leaderboardCollection,
|
|
36
36
|
string nextPage,
|
|
37
|
-
string periodToken
|
|
38
|
-
|
|
39
|
-
_platform.LoadLeaderboardScores(leaderboardId, leaderboardCollection, nextPage, periodToken
|
|
37
|
+
string periodToken)
|
|
38
|
+
{
|
|
39
|
+
return _platform.LoadLeaderboardScores(leaderboardId, leaderboardCollection, nextPage, periodToken);
|
|
40
|
+
}
|
|
40
41
|
|
|
41
|
-
public
|
|
42
|
+
public Task<UserScoreResponse> LoadCurrentPlayerLeaderboardScore(string leaderboardId,
|
|
42
43
|
string leaderboardCollection,
|
|
43
|
-
string periodToken
|
|
44
|
-
ITapTapLeaderboardResponseCallback<UserScoreResponse> callback)
|
|
44
|
+
string periodToken)
|
|
45
45
|
{
|
|
46
|
-
_platform.LoadCurrentPlayerLeaderboardScore(leaderboardId, leaderboardCollection, periodToken
|
|
46
|
+
return _platform.LoadCurrentPlayerLeaderboardScore(leaderboardId, leaderboardCollection, periodToken);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
public
|
|
49
|
+
public Task<LeaderboardScoreResponse> LoadPlayerCenteredScores(string leaderboardId,
|
|
50
50
|
string leaderboardCollection,
|
|
51
51
|
string periodToken,
|
|
52
|
-
int? maxCount
|
|
53
|
-
ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback)
|
|
52
|
+
int? maxCount)
|
|
54
53
|
{
|
|
55
|
-
_platform.LoadPlayerCenteredScores(leaderboardId, leaderboardCollection, periodToken, maxCount
|
|
54
|
+
return _platform.LoadPlayerCenteredScores(leaderboardId, leaderboardCollection, periodToken, maxCount);
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
public void RegisterLeaderboardCallback(ITapTapLeaderboardCallback callback)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
using System.Collections.Generic;
|
|
2
|
+
using System.Threading.Tasks;
|
|
2
3
|
|
|
3
4
|
namespace TapSDK.Leaderboard
|
|
4
5
|
{
|
|
@@ -25,9 +26,8 @@ namespace TapSDK.Leaderboard
|
|
|
25
26
|
/// 提交分数
|
|
26
27
|
/// </summary>
|
|
27
28
|
/// <param name="scores">分数列表</param>
|
|
28
|
-
/// <
|
|
29
|
-
|
|
30
|
-
ITapTapLeaderboardResponseCallback<SubmitScoresResponse> callback);
|
|
29
|
+
/// <returns>提交结果</returns>
|
|
30
|
+
Task<SubmitScoresResponse> SubmitScores(List<SubmitScoresRequest.ScoreItem> scores);
|
|
31
31
|
|
|
32
32
|
/// <summary>
|
|
33
33
|
/// 加载排行榜分数
|
|
@@ -36,13 +36,12 @@ namespace TapSDK.Leaderboard
|
|
|
36
36
|
/// <param name="leaderboardCollection">排行榜集合类型</param>
|
|
37
37
|
/// <param name="nextPage">下一页标识</param>
|
|
38
38
|
/// <param name="periodToken">周期标识</param>
|
|
39
|
-
/// <
|
|
40
|
-
|
|
39
|
+
/// <returns>排行榜分数结果</returns>
|
|
40
|
+
Task<LeaderboardScoreResponse> LoadLeaderboardScores(
|
|
41
41
|
string leaderboardId,
|
|
42
42
|
string leaderboardCollection,
|
|
43
43
|
string nextPage,
|
|
44
|
-
string periodToken
|
|
45
|
-
ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback);
|
|
44
|
+
string periodToken);
|
|
46
45
|
|
|
47
46
|
/// <summary>
|
|
48
47
|
/// 加载当前玩家排行榜分数
|
|
@@ -50,11 +49,10 @@ namespace TapSDK.Leaderboard
|
|
|
50
49
|
/// <param name="leaderboardId">排行榜ID</param>
|
|
51
50
|
/// <param name="leaderboardCollection">排行榜集合类型</param>
|
|
52
51
|
/// <param name="periodToken">周期标识</param>
|
|
53
|
-
/// <
|
|
54
|
-
|
|
52
|
+
/// <returns>用户分数结果</returns>
|
|
53
|
+
Task<UserScoreResponse> LoadCurrentPlayerLeaderboardScore(string leaderboardId,
|
|
55
54
|
string leaderboardCollection,
|
|
56
|
-
string periodToken
|
|
57
|
-
ITapTapLeaderboardResponseCallback<UserScoreResponse> callback);
|
|
55
|
+
string periodToken);
|
|
58
56
|
|
|
59
57
|
/// <summary>
|
|
60
58
|
/// 加载以玩家为中心的分数
|
|
@@ -63,12 +61,11 @@ namespace TapSDK.Leaderboard
|
|
|
63
61
|
/// <param name="leaderboardCollection">排行榜集合类型</param>
|
|
64
62
|
/// <param name="periodToken">周期标识</param>
|
|
65
63
|
/// <param name="maxCount">最大数量</param>
|
|
66
|
-
/// <
|
|
67
|
-
|
|
64
|
+
/// <returns>排行榜分数结果</returns>
|
|
65
|
+
Task<LeaderboardScoreResponse> LoadPlayerCenteredScores(string leaderboardId,
|
|
68
66
|
string leaderboardCollection,
|
|
69
67
|
string periodToken,
|
|
70
|
-
int? maxCount
|
|
71
|
-
ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback);
|
|
68
|
+
int? maxCount);
|
|
72
69
|
|
|
73
70
|
/// <summary>
|
|
74
71
|
/// 设置分享回调
|
|
@@ -13,7 +13,7 @@ namespace TapSDK.Leaderboard
|
|
|
13
13
|
/// <summary>
|
|
14
14
|
/// SDK版本号
|
|
15
15
|
/// </summary>
|
|
16
|
-
public static readonly string Version = "4.8.
|
|
16
|
+
public static readonly string Version = "4.8.2";
|
|
17
17
|
|
|
18
18
|
/// <summary>
|
|
19
19
|
/// 打开排行榜页面
|
|
@@ -39,11 +39,10 @@ namespace TapSDK.Leaderboard
|
|
|
39
39
|
/// 批量提交用户排行榜分数(一次最多提交5个分数)
|
|
40
40
|
/// </summary>
|
|
41
41
|
/// <param name="scores">分数列表</param>
|
|
42
|
-
/// <
|
|
43
|
-
public static
|
|
44
|
-
ITapTapLeaderboardResponseCallback<SubmitScoresResponse> callback)
|
|
42
|
+
/// <returns>提交结果</returns>
|
|
43
|
+
public static Task<SubmitScoresResponse> SubmitScores(List<SubmitScoresRequest.ScoreItem> scores)
|
|
45
44
|
{
|
|
46
|
-
TapTapLeaderboardManager.Instance.SubmitScores(scores
|
|
45
|
+
return TapTapLeaderboardManager.Instance.SubmitScores(scores);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
/// <summary>
|
|
@@ -53,20 +52,18 @@ namespace TapSDK.Leaderboard
|
|
|
53
52
|
/// <param name="leaderboardCollection">排行榜集合</param>
|
|
54
53
|
/// <param name="nextPage">下一页标识</param>
|
|
55
54
|
/// <param name="periodToken">周期标识</param>
|
|
56
|
-
/// <
|
|
57
|
-
public static
|
|
55
|
+
/// <returns>排行榜分数结果</returns>
|
|
56
|
+
public static Task<LeaderboardScoreResponse> LoadLeaderboardScores(
|
|
58
57
|
string leaderboardId,
|
|
59
58
|
string leaderboardCollection,
|
|
60
59
|
string nextPage,
|
|
61
|
-
string periodToken
|
|
62
|
-
ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback)
|
|
60
|
+
string periodToken)
|
|
63
61
|
{
|
|
64
|
-
TapTapLeaderboardManager.Instance.LoadLeaderboardScores(
|
|
62
|
+
return TapTapLeaderboardManager.Instance.LoadLeaderboardScores(
|
|
65
63
|
leaderboardId,
|
|
66
64
|
leaderboardCollection,
|
|
67
65
|
nextPage,
|
|
68
|
-
periodToken
|
|
69
|
-
callback
|
|
66
|
+
periodToken
|
|
70
67
|
);
|
|
71
68
|
}
|
|
72
69
|
|
|
@@ -76,18 +73,16 @@ namespace TapSDK.Leaderboard
|
|
|
76
73
|
/// <param name="leaderboardId">排行榜ID</param>
|
|
77
74
|
/// <param name="leaderboardCollection">排行榜集合</param>
|
|
78
75
|
/// <param name="periodToken">周期标识</param>
|
|
79
|
-
/// <
|
|
80
|
-
public static
|
|
76
|
+
/// <returns>用户分数结果</returns>
|
|
77
|
+
public static Task<UserScoreResponse> LoadCurrentPlayerLeaderboardScore(
|
|
81
78
|
string leaderboardId,
|
|
82
79
|
string leaderboardCollection,
|
|
83
|
-
string periodToken
|
|
84
|
-
ITapTapLeaderboardResponseCallback<UserScoreResponse> callback)
|
|
80
|
+
string periodToken)
|
|
85
81
|
{
|
|
86
|
-
TapTapLeaderboardManager.Instance.LoadCurrentPlayerLeaderboardScore(
|
|
82
|
+
return TapTapLeaderboardManager.Instance.LoadCurrentPlayerLeaderboardScore(
|
|
87
83
|
leaderboardId,
|
|
88
84
|
leaderboardCollection,
|
|
89
|
-
periodToken
|
|
90
|
-
callback
|
|
85
|
+
periodToken
|
|
91
86
|
);
|
|
92
87
|
}
|
|
93
88
|
|
|
@@ -98,20 +93,18 @@ namespace TapSDK.Leaderboard
|
|
|
98
93
|
/// <param name="leaderboardCollection">排行榜集合</param>
|
|
99
94
|
/// <param name="periodToken">周期标识</param>
|
|
100
95
|
/// <param name="maxCount">最大数量,-1表示不限制</param>
|
|
101
|
-
/// <
|
|
102
|
-
public static
|
|
96
|
+
/// <returns>排行榜分数结果</returns>
|
|
97
|
+
public static Task<LeaderboardScoreResponse> LoadPlayerCenteredScores(
|
|
103
98
|
string leaderboardId,
|
|
104
99
|
string leaderboardCollection,
|
|
105
100
|
string periodToken,
|
|
106
|
-
int? maxCount
|
|
107
|
-
ITapTapLeaderboardResponseCallback<LeaderboardScoreResponse> callback)
|
|
101
|
+
int? maxCount)
|
|
108
102
|
{
|
|
109
|
-
TapTapLeaderboardManager.Instance.LoadPlayerCenteredScores(
|
|
103
|
+
return TapTapLeaderboardManager.Instance.LoadPlayerCenteredScores(
|
|
110
104
|
leaderboardId,
|
|
111
105
|
leaderboardCollection,
|
|
112
106
|
periodToken,
|
|
113
|
-
maxCount
|
|
114
|
-
callback
|
|
107
|
+
maxCount
|
|
115
108
|
);
|
|
116
109
|
}
|
|
117
110
|
|
package/package.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"name": "com.taptap.sdk.leaderboard",
|
|
3
3
|
"displayName": "TapTapSDK Leaderboard",
|
|
4
4
|
"description": "TapTapSDK Leaderboard",
|
|
5
|
-
"version": "4.8.
|
|
5
|
+
"version": "4.8.2",
|
|
6
6
|
"unity": "2019.4",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"com.taptap.sdk.core": "4.8.
|
|
10
|
-
"com.taptap.sdk.login": "4.8.
|
|
9
|
+
"com.taptap.sdk.core": "4.8.2",
|
|
10
|
+
"com.taptap.sdk.login": "4.8.2"
|
|
11
11
|
}
|
|
12
12
|
}
|