com.taptap.sdk.cloudsave 4.8.1-beta.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/NativeDependencies.xml +3 -3
- package/Mobile/Editor/TapCloudSaveMobileProcessBuild.cs +1 -0
- package/Mobile/Runtime/TapCloudSaveBridge.cs +71 -61
- package/Runtime/Internal/ITapCloudSaveBridge.cs +10 -9
- package/Runtime/Internal/TapTapCloudSaveInternal.cs +15 -28
- package/Runtime/Public/TapTapCloudSave.cs +17 -30
- package/Standalone/Runtime/TapCloudSaveStandalone.cs +60 -121
- package/package.json +3 -3
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
<?xml version="1.0" ?>
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
2
|
<dependencies>
|
|
3
3
|
<androidPackages>
|
|
4
4
|
<repositories>
|
|
5
5
|
<repository>https://repo.maven.apache.org/maven2</repository>
|
|
6
6
|
</repositories>
|
|
7
|
-
<androidPackage spec="com.taptap.sdk:tap-cloudsave-unity:4.8.
|
|
7
|
+
<androidPackage spec="com.taptap.sdk:tap-cloudsave-unity:4.8.2"/>
|
|
8
8
|
</androidPackages>
|
|
9
9
|
<iosPods>
|
|
10
10
|
<sources>
|
|
11
11
|
<source>https://github.com/CocoaPods/Specs.git</source>
|
|
12
12
|
</sources>
|
|
13
|
-
<iosPod
|
|
13
|
+
<iosPod addToAllTargets="false" bitcodeEnabled="false" name="TapTapCloudSaveSDK" version="4.8.2"/>
|
|
14
14
|
</iosPods>
|
|
15
15
|
</dependencies>
|
|
@@ -9,6 +9,7 @@ namespace TapSDK.CloudSave.Mobile.Editor {
|
|
|
9
9
|
public override string LinkPath => "TapSDK/CloudSave/link.xml";
|
|
10
10
|
|
|
11
11
|
public override LinkedAssembly[] LinkedAssemblies => new LinkedAssembly[] {
|
|
12
|
+
new LinkedAssembly { Fullname = "TapSDK.CloudSave.Runtime" },
|
|
12
13
|
new LinkedAssembly { Fullname = "TapSDK.CloudSave.Mobile.Runtime" }
|
|
13
14
|
};
|
|
14
15
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
using System.Collections.Generic;
|
|
2
2
|
using TapSDK.Core;
|
|
3
3
|
using System;
|
|
4
|
+
using System.Threading.Tasks;
|
|
4
5
|
using Newtonsoft.Json;
|
|
5
6
|
using TapSDK.CloudSave.Internal;
|
|
7
|
+
using TapSDK.Core.Internal.Log;
|
|
6
8
|
|
|
7
9
|
namespace TapSDK.CloudSave.Mobile
|
|
8
10
|
{
|
|
@@ -32,6 +34,7 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
32
34
|
|
|
33
35
|
public void RegisterCloudSaveCallback(ITapCloudSaveCallback callback)
|
|
34
36
|
{
|
|
37
|
+
TapLog.Log("[TapCloudSaveBridge] RegisterCloudSaveCallback called (UNCHANGED callback pattern)");
|
|
35
38
|
EngineBridge.GetInstance().CallHandler(new Command.Builder()
|
|
36
39
|
.Service(TAP_CLOUDSAVE_SERVICE)
|
|
37
40
|
.Method("registerCloudSaveCallback")
|
|
@@ -74,8 +77,10 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
public
|
|
80
|
+
public Task<ArchiveData> CreateArchive(ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath)
|
|
78
81
|
{
|
|
82
|
+
TapLog.Log("[TapCloudSaveBridge] CreateArchive called with Task<ArchiveData> return type (NEW API)");
|
|
83
|
+
var taskSource = new TaskCompletionSource<ArchiveData>();
|
|
79
84
|
EngineBridge.GetInstance().CallHandler(new Command.Builder()
|
|
80
85
|
.Service(TAP_CLOUDSAVE_SERVICE)
|
|
81
86
|
.Method("createArchive")
|
|
@@ -84,15 +89,14 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
84
89
|
.Args("archiveCoverPath", archiveCoverPath)
|
|
85
90
|
.Callback(true)
|
|
86
91
|
.OnceTime(true)
|
|
87
|
-
.CommandBuilder(),
|
|
92
|
+
.CommandBuilder(),
|
|
93
|
+
response =>
|
|
88
94
|
{
|
|
89
|
-
if (callback == null) return;
|
|
90
|
-
|
|
91
95
|
try
|
|
92
96
|
{
|
|
93
97
|
if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
|
|
94
98
|
{
|
|
95
|
-
|
|
99
|
+
taskSource.TrySetException(new TapException(-1, "Failed to create archive: code="+response.code + " content="+response.content));
|
|
96
100
|
return;
|
|
97
101
|
}
|
|
98
102
|
|
|
@@ -102,11 +106,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
102
106
|
var archive = JsonConvert.DeserializeObject<ArchiveData>(result.content);
|
|
103
107
|
if (archive != null)
|
|
104
108
|
{
|
|
105
|
-
|
|
109
|
+
taskSource.TrySetResult(archive);
|
|
106
110
|
}
|
|
107
111
|
else
|
|
108
112
|
{
|
|
109
|
-
|
|
113
|
+
taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
else
|
|
@@ -116,28 +120,31 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
116
120
|
var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
|
|
117
121
|
if (errorResponse != null)
|
|
118
122
|
{
|
|
119
|
-
|
|
123
|
+
taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
|
|
120
124
|
}
|
|
121
125
|
else
|
|
122
126
|
{
|
|
123
|
-
|
|
127
|
+
taskSource.TrySetException(new TapException(-1, "Failed to create archive: content="+response.content));
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
catch (Exception e)
|
|
127
131
|
{
|
|
128
|
-
|
|
132
|
+
taskSource.TrySetException(new TapException(-1, "Failed to create archive: content="+response.content));
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
catch (Exception e)
|
|
133
137
|
{
|
|
134
|
-
|
|
138
|
+
taskSource.TrySetException(new TapException(-1, "Failed to create archive: error=" + e.Message + ", content=" + response.content));
|
|
135
139
|
}
|
|
136
140
|
});
|
|
141
|
+
return taskSource.Task;
|
|
137
142
|
}
|
|
138
143
|
|
|
139
|
-
public
|
|
144
|
+
public Task<ArchiveData> UpdateArchive(string archiveUuid, ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath)
|
|
140
145
|
{
|
|
146
|
+
TapLog.Log("[TapCloudSaveBridge] UpdateArchive called with Task<ArchiveData> return type (NEW API)");
|
|
147
|
+
var taskSource = new TaskCompletionSource<ArchiveData>();
|
|
141
148
|
EngineBridge.GetInstance().CallHandler(new Command.Builder()
|
|
142
149
|
.Service(TAP_CLOUDSAVE_SERVICE)
|
|
143
150
|
.Method("updateArchive")
|
|
@@ -149,13 +156,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
149
156
|
.OnceTime(true)
|
|
150
157
|
.CommandBuilder(), (response) =>
|
|
151
158
|
{
|
|
152
|
-
if (callback == null) return;
|
|
153
|
-
|
|
154
159
|
try
|
|
155
160
|
{
|
|
156
161
|
if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
|
|
157
162
|
{
|
|
158
|
-
|
|
163
|
+
taskSource.TrySetException(new TapException(-1, "Failed to update archive: code="+response.code + " content="+response.content));
|
|
159
164
|
return;
|
|
160
165
|
}
|
|
161
166
|
|
|
@@ -165,11 +170,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
165
170
|
var archive = JsonConvert.DeserializeObject<ArchiveData>(result.content);
|
|
166
171
|
if (archive != null)
|
|
167
172
|
{
|
|
168
|
-
|
|
173
|
+
taskSource.TrySetResult(archive);
|
|
169
174
|
}
|
|
170
175
|
else
|
|
171
176
|
{
|
|
172
|
-
|
|
177
|
+
taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
|
|
173
178
|
}
|
|
174
179
|
}
|
|
175
180
|
else
|
|
@@ -179,28 +184,31 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
179
184
|
var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
|
|
180
185
|
if (errorResponse != null)
|
|
181
186
|
{
|
|
182
|
-
|
|
187
|
+
taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
|
|
183
188
|
}
|
|
184
189
|
else
|
|
185
190
|
{
|
|
186
|
-
|
|
191
|
+
taskSource.TrySetException(new TapException(-1, "Failed to update archive: content="+response.content));
|
|
187
192
|
}
|
|
188
193
|
}
|
|
189
194
|
catch (Exception e)
|
|
190
195
|
{
|
|
191
|
-
|
|
196
|
+
taskSource.TrySetException(new TapException(-1, "Failed to update archive: content="+response.content));
|
|
192
197
|
}
|
|
193
198
|
}
|
|
194
199
|
}
|
|
195
200
|
catch (Exception e)
|
|
196
201
|
{
|
|
197
|
-
|
|
202
|
+
taskSource.TrySetException(new TapException(-1, "Failed to update archive: error=" + e.Message + ", content=" + response.content));
|
|
198
203
|
}
|
|
199
204
|
});
|
|
205
|
+
return taskSource.Task;
|
|
200
206
|
}
|
|
201
207
|
|
|
202
|
-
public
|
|
208
|
+
public Task<ArchiveData> DeleteArchive(string archiveUuid)
|
|
203
209
|
{
|
|
210
|
+
TapLog.Log("[TapCloudSaveBridge] DeleteArchive called with Task<ArchiveData> return type (NEW API)");
|
|
211
|
+
var taskSource = new TaskCompletionSource<ArchiveData>();
|
|
204
212
|
EngineBridge.GetInstance().CallHandler(new Command.Builder()
|
|
205
213
|
.Service(TAP_CLOUDSAVE_SERVICE)
|
|
206
214
|
.Method("deleteArchive")
|
|
@@ -209,13 +217,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
209
217
|
.OnceTime(true)
|
|
210
218
|
.CommandBuilder(), (response) =>
|
|
211
219
|
{
|
|
212
|
-
if (callback == null) return;
|
|
213
|
-
|
|
214
220
|
try
|
|
215
221
|
{
|
|
216
222
|
if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
|
|
217
223
|
{
|
|
218
|
-
|
|
224
|
+
taskSource.TrySetException(new TapException(-1, "Failed to delete archive: code="+response.code + " content="+response.content));
|
|
219
225
|
return;
|
|
220
226
|
}
|
|
221
227
|
|
|
@@ -225,11 +231,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
225
231
|
var archive = JsonConvert.DeserializeObject<ArchiveData>(result.content);
|
|
226
232
|
if (archive != null)
|
|
227
233
|
{
|
|
228
|
-
|
|
234
|
+
taskSource.TrySetResult(archive);
|
|
229
235
|
}
|
|
230
236
|
else
|
|
231
237
|
{
|
|
232
|
-
|
|
238
|
+
taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
|
|
233
239
|
}
|
|
234
240
|
}
|
|
235
241
|
else
|
|
@@ -239,28 +245,31 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
239
245
|
var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
|
|
240
246
|
if (errorResponse != null)
|
|
241
247
|
{
|
|
242
|
-
|
|
248
|
+
taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
|
|
243
249
|
}
|
|
244
250
|
else
|
|
245
251
|
{
|
|
246
|
-
|
|
252
|
+
taskSource.TrySetException(new TapException(-1, "Failed to delete archive: content="+response.content));
|
|
247
253
|
}
|
|
248
254
|
}
|
|
249
255
|
catch (Exception e)
|
|
250
256
|
{
|
|
251
|
-
|
|
257
|
+
taskSource.TrySetException(new TapException(-1, "Failed to delete archive: content="+response.content));
|
|
252
258
|
}
|
|
253
259
|
}
|
|
254
260
|
}
|
|
255
261
|
catch (Exception e)
|
|
256
262
|
{
|
|
257
|
-
|
|
263
|
+
taskSource.TrySetException(new TapException(-1, "Failed to delete archive: error=" + e.Message + ", content=" + response.content));
|
|
258
264
|
}
|
|
259
265
|
});
|
|
266
|
+
return taskSource.Task;
|
|
260
267
|
}
|
|
261
268
|
|
|
262
|
-
public
|
|
269
|
+
public Task<List<ArchiveData>> GetArchiveList()
|
|
263
270
|
{
|
|
271
|
+
TapLog.Log("[TapCloudSaveBridge] GetArchiveList called with Task<List<ArchiveData>> return type (NEW API)");
|
|
272
|
+
var taskSource = new TaskCompletionSource<List<ArchiveData>>();
|
|
264
273
|
EngineBridge.GetInstance().CallHandler(new Command.Builder()
|
|
265
274
|
.Service(TAP_CLOUDSAVE_SERVICE)
|
|
266
275
|
.Method("getArchiveList")
|
|
@@ -268,13 +277,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
268
277
|
.OnceTime(true)
|
|
269
278
|
.CommandBuilder(), (response) =>
|
|
270
279
|
{
|
|
271
|
-
if (callback == null) return;
|
|
272
|
-
|
|
273
280
|
try
|
|
274
281
|
{
|
|
275
282
|
if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
|
|
276
283
|
{
|
|
277
|
-
|
|
284
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive list: code="+response.code + " content="+response.content));
|
|
278
285
|
return;
|
|
279
286
|
}
|
|
280
287
|
|
|
@@ -284,11 +291,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
284
291
|
var archiveList = JsonConvert.DeserializeObject<List<ArchiveData>>(result.content);
|
|
285
292
|
if (archiveList != null)
|
|
286
293
|
{
|
|
287
|
-
|
|
294
|
+
taskSource.TrySetResult(archiveList);
|
|
288
295
|
}
|
|
289
296
|
else
|
|
290
297
|
{
|
|
291
|
-
|
|
298
|
+
taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
|
|
292
299
|
}
|
|
293
300
|
}
|
|
294
301
|
else
|
|
@@ -298,28 +305,31 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
298
305
|
var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
|
|
299
306
|
if (errorResponse != null)
|
|
300
307
|
{
|
|
301
|
-
|
|
308
|
+
taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
|
|
302
309
|
}
|
|
303
310
|
else
|
|
304
311
|
{
|
|
305
|
-
|
|
312
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive list: content="+response.content));
|
|
306
313
|
}
|
|
307
314
|
}
|
|
308
315
|
catch (Exception e)
|
|
309
316
|
{
|
|
310
|
-
|
|
317
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive list: content="+response.content));
|
|
311
318
|
}
|
|
312
319
|
}
|
|
313
320
|
}
|
|
314
321
|
catch (Exception e)
|
|
315
322
|
{
|
|
316
|
-
|
|
323
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive list: error=" + e.Message + ", content=" + response.content));
|
|
317
324
|
}
|
|
318
325
|
});
|
|
326
|
+
return taskSource.Task;
|
|
319
327
|
}
|
|
320
328
|
|
|
321
|
-
public
|
|
329
|
+
public Task<byte[]> GetArchiveData(string archiveUuid, string archiveFileId)
|
|
322
330
|
{
|
|
331
|
+
TapLog.Log("[TapCloudSaveBridge] GetArchiveData called with Task<byte[]> return type (NEW API)");
|
|
332
|
+
var taskSource = new TaskCompletionSource<byte[]>();
|
|
323
333
|
EngineBridge.GetInstance().CallHandler(new Command.Builder()
|
|
324
334
|
.Service(TAP_CLOUDSAVE_SERVICE)
|
|
325
335
|
.Method("getArchiveData")
|
|
@@ -329,13 +339,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
329
339
|
.OnceTime(true)
|
|
330
340
|
.CommandBuilder(), (response) =>
|
|
331
341
|
{
|
|
332
|
-
if (callback == null) return;
|
|
333
|
-
|
|
334
342
|
try
|
|
335
343
|
{
|
|
336
344
|
if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
|
|
337
345
|
{
|
|
338
|
-
|
|
346
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive data: code=" + response.code + " content="+response.content));
|
|
339
347
|
return;
|
|
340
348
|
}
|
|
341
349
|
|
|
@@ -345,11 +353,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
345
353
|
var archiveData = Convert.FromBase64String(result.content);
|
|
346
354
|
if (archiveData != null)
|
|
347
355
|
{
|
|
348
|
-
|
|
356
|
+
taskSource.TrySetResult(archiveData);
|
|
349
357
|
}
|
|
350
358
|
else
|
|
351
359
|
{
|
|
352
|
-
|
|
360
|
+
taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
|
|
353
361
|
}
|
|
354
362
|
}
|
|
355
363
|
else
|
|
@@ -359,28 +367,31 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
359
367
|
var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
|
|
360
368
|
if (errorResponse != null)
|
|
361
369
|
{
|
|
362
|
-
|
|
370
|
+
taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
|
|
363
371
|
}
|
|
364
372
|
else
|
|
365
373
|
{
|
|
366
|
-
|
|
374
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive data: content="+response.content));
|
|
367
375
|
}
|
|
368
376
|
}
|
|
369
377
|
catch (Exception e)
|
|
370
378
|
{
|
|
371
|
-
|
|
379
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive data: content="+response.content));
|
|
372
380
|
}
|
|
373
381
|
}
|
|
374
382
|
}
|
|
375
383
|
catch (Exception e)
|
|
376
384
|
{
|
|
377
|
-
|
|
385
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive data: error=" + e.Message + ", content=" + response.content));
|
|
378
386
|
}
|
|
379
387
|
});
|
|
388
|
+
return taskSource.Task;
|
|
380
389
|
}
|
|
381
390
|
|
|
382
|
-
public
|
|
391
|
+
public Task<byte[]> GetArchiveCover(string archiveUuid, string archiveFileId)
|
|
383
392
|
{
|
|
393
|
+
TapLog.Log("[TapCloudSaveBridge] GetArchiveCover called with Task<byte[]> return type (NEW API)");
|
|
394
|
+
var taskSource = new TaskCompletionSource<byte[]>();
|
|
384
395
|
EngineBridge.GetInstance().CallHandler(new Command.Builder()
|
|
385
396
|
.Service(TAP_CLOUDSAVE_SERVICE)
|
|
386
397
|
.Method("getArchiveCover")
|
|
@@ -390,13 +401,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
390
401
|
.OnceTime(true)
|
|
391
402
|
.CommandBuilder(), (response) =>
|
|
392
403
|
{
|
|
393
|
-
if (callback == null) return;
|
|
394
|
-
|
|
395
404
|
try
|
|
396
405
|
{
|
|
397
406
|
if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
|
|
398
407
|
{
|
|
399
|
-
|
|
408
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive cover: code="+response.code + " content="+response.content));
|
|
400
409
|
return;
|
|
401
410
|
}
|
|
402
411
|
|
|
@@ -406,11 +415,11 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
406
415
|
var coverData = Convert.FromBase64String(result.content);
|
|
407
416
|
if (coverData != null)
|
|
408
417
|
{
|
|
409
|
-
|
|
418
|
+
taskSource.TrySetResult(coverData);
|
|
410
419
|
}
|
|
411
420
|
else
|
|
412
421
|
{
|
|
413
|
-
|
|
422
|
+
taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
|
|
414
423
|
}
|
|
415
424
|
}
|
|
416
425
|
else
|
|
@@ -420,24 +429,25 @@ namespace TapSDK.CloudSave.Mobile
|
|
|
420
429
|
var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
|
|
421
430
|
if (errorResponse != null)
|
|
422
431
|
{
|
|
423
|
-
|
|
432
|
+
taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
|
|
424
433
|
}
|
|
425
434
|
else
|
|
426
435
|
{
|
|
427
|
-
|
|
436
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive cover: content="+response.content));
|
|
428
437
|
}
|
|
429
438
|
}
|
|
430
439
|
catch (Exception e)
|
|
431
440
|
{
|
|
432
|
-
|
|
441
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive cover: content="+response.content));
|
|
433
442
|
}
|
|
434
443
|
}
|
|
435
444
|
}
|
|
436
445
|
catch (Exception e)
|
|
437
446
|
{
|
|
438
|
-
|
|
447
|
+
taskSource.TrySetException(new TapException(-1, "Failed to get archive cover: error=" + e.Message + ", content=" + response.content));
|
|
439
448
|
}
|
|
440
449
|
});
|
|
450
|
+
return taskSource.Task;
|
|
441
451
|
}
|
|
442
452
|
}
|
|
443
453
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
using
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using TapSDK.Core;
|
|
2
5
|
|
|
3
6
|
namespace TapSDK.CloudSave.Internal
|
|
4
7
|
{
|
|
@@ -8,15 +11,13 @@ namespace TapSDK.CloudSave.Internal
|
|
|
8
11
|
|
|
9
12
|
void RegisterCloudSaveCallback(ITapCloudSaveCallback callback);
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
ITapCloudSaveRequestCallback callback);
|
|
14
|
+
Task<ArchiveData> CreateArchive(ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath);
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
ITapCloudSaveRequestCallback callback);
|
|
16
|
+
Task<ArchiveData> UpdateArchive(string archiveUuid, ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath);
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
Task<ArchiveData> DeleteArchive(string archiveUuid);
|
|
19
|
+
Task<List<ArchiveData>> GetArchiveList();
|
|
20
|
+
Task<byte[]> GetArchiveData(string archiveUuid, string archiveFileId);
|
|
21
|
+
Task<byte[]> GetArchiveCover(string archiveUuid, string archiveFileId);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
1
4
|
using TapSDK.Core;
|
|
2
5
|
using TapSDK.Core.Internal.Utils;
|
|
3
6
|
|
|
@@ -23,38 +26,22 @@ namespace TapSDK.CloudSave.Internal
|
|
|
23
26
|
Bridge?.RegisterCloudSaveCallback(callback);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
internal static
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
Bridge?.CreateArchive(metadata, archiveFilePath, archiveCoverPath, callback);
|
|
30
|
-
}
|
|
29
|
+
internal static Task<ArchiveData> CreateArchive(ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath) =>
|
|
30
|
+
Bridge?.CreateArchive(metadata, archiveFilePath, archiveCoverPath);
|
|
31
31
|
|
|
32
|
-
internal static
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
Bridge?.UpdateArchive(archiveUuid, metadata, archiveFilePath, archiveCoverPath, callback);
|
|
36
|
-
}
|
|
32
|
+
internal static Task<ArchiveData> UpdateArchive(string archiveUuid, ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath) =>
|
|
33
|
+
Bridge?.UpdateArchive(archiveUuid, metadata, archiveFilePath, archiveCoverPath);
|
|
37
34
|
|
|
38
|
-
internal static
|
|
39
|
-
|
|
40
|
-
Bridge?.DeleteArchive(archiveUuid, callback);
|
|
41
|
-
}
|
|
35
|
+
internal static Task<ArchiveData> DeleteArchive(string archiveUuid) =>
|
|
36
|
+
Bridge?.DeleteArchive(archiveUuid);
|
|
42
37
|
|
|
43
|
-
internal static
|
|
44
|
-
|
|
45
|
-
Bridge?.GetArchiveList(callback);
|
|
46
|
-
}
|
|
38
|
+
internal static Task<List<ArchiveData>> GetArchiveList() =>
|
|
39
|
+
Bridge?.GetArchiveList();
|
|
47
40
|
|
|
48
|
-
internal static
|
|
49
|
-
|
|
50
|
-
{
|
|
51
|
-
Bridge?.GetArchiveData(archiveUuid, archiveFileId, callback);
|
|
52
|
-
}
|
|
41
|
+
internal static Task<byte[]> GetArchiveData(string archiveUuid, string archiveFileId) =>
|
|
42
|
+
Bridge?.GetArchiveData(archiveUuid, archiveFileId);
|
|
53
43
|
|
|
54
|
-
internal static
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
Bridge?.GetArchiveCover(archiveUuid, archiveFileId, callback);
|
|
58
|
-
}
|
|
44
|
+
internal static Task<byte[]> GetArchiveCover(string archiveUuid, string archiveFileId) =>
|
|
45
|
+
Bridge?.GetArchiveCover(archiveUuid, archiveFileId);
|
|
59
46
|
}
|
|
60
47
|
}
|
|
@@ -1,48 +1,35 @@
|
|
|
1
|
-
using
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using TapSDK.CloudSave.Internal;
|
|
2
5
|
|
|
3
6
|
namespace TapSDK.CloudSave
|
|
4
7
|
{
|
|
5
8
|
public class TapTapCloudSave
|
|
6
9
|
{
|
|
7
|
-
public static readonly string Version = "4.8.
|
|
10
|
+
public static readonly string Version = "4.8.2";
|
|
8
11
|
|
|
9
12
|
public static void RegisterCloudSaveCallback(ITapCloudSaveCallback callback)
|
|
10
13
|
{
|
|
11
14
|
TapTapCloudSaveInternal.RegisterCloudSaveCallback(callback);
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
public static
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
TapTapCloudSaveInternal.CreateArchive(metadata, archiveFilePath, archiveCoverPath, callback);
|
|
18
|
-
}
|
|
17
|
+
public static Task<ArchiveData> CreateArchive(ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath) =>
|
|
18
|
+
TapTapCloudSaveInternal.CreateArchive(metadata, archiveFilePath, archiveCoverPath);
|
|
19
19
|
|
|
20
|
-
public static
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
TapTapCloudSaveInternal.UpdateArchive(archiveUuid, metadata, archiveFilePath, archiveCoverPath, callback);
|
|
24
|
-
}
|
|
20
|
+
public static Task<ArchiveData> UpdateArchive(string archiveUuid, ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath) =>
|
|
21
|
+
TapTapCloudSaveInternal.UpdateArchive(archiveUuid, metadata, archiveFilePath, archiveCoverPath);
|
|
25
22
|
|
|
26
|
-
public static
|
|
27
|
-
|
|
28
|
-
TapTapCloudSaveInternal.DeleteArchive(archiveUuid, callback);
|
|
29
|
-
}
|
|
23
|
+
public static Task<ArchiveData> DeleteArchive(string archiveUuid) =>
|
|
24
|
+
TapTapCloudSaveInternal.DeleteArchive(archiveUuid);
|
|
30
25
|
|
|
31
|
-
public static
|
|
32
|
-
|
|
33
|
-
TapTapCloudSaveInternal.GetArchiveList(callback);
|
|
34
|
-
}
|
|
26
|
+
public static Task<List<ArchiveData>> GetArchiveList() =>
|
|
27
|
+
TapTapCloudSaveInternal.GetArchiveList();
|
|
35
28
|
|
|
36
|
-
public static
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
TapTapCloudSaveInternal.GetArchiveData(archiveUuid, archiveFileId, callback);
|
|
40
|
-
}
|
|
29
|
+
public static Task<byte[]> GetArchiveData(string archiveUuid, string archiveFileId) =>
|
|
30
|
+
TapTapCloudSaveInternal.GetArchiveData(archiveUuid, archiveFileId);
|
|
41
31
|
|
|
42
|
-
public static
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
TapTapCloudSaveInternal.GetArchiveCover(archiveUuid, archiveFileId, callback);
|
|
46
|
-
}
|
|
32
|
+
public static Task<byte[]> GetArchiveCover(string archiveUuid, string archiveFileId) =>
|
|
33
|
+
TapTapCloudSaveInternal.GetArchiveCover(archiveUuid, archiveFileId);
|
|
47
34
|
}
|
|
48
35
|
}
|
|
@@ -102,13 +102,13 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
102
102
|
EventManager.AddListener(EventManager.OnTapUserChanged, OnLoginInfoChanged);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
public
|
|
105
|
+
public Task<ArchiveData> CreateArchive(
|
|
106
106
|
ArchiveMetadata metadata,
|
|
107
107
|
string archiveFilePath,
|
|
108
|
-
string archiveCoverPath
|
|
109
|
-
ITapCloudSaveRequestCallback callback
|
|
108
|
+
string archiveCoverPath
|
|
110
109
|
)
|
|
111
110
|
{
|
|
111
|
+
var taskSource = new TaskCompletionSource<ArchiveData>();
|
|
112
112
|
CheckPCLaunchState();
|
|
113
113
|
string seesionId = Guid.NewGuid().ToString();
|
|
114
114
|
const string method = "createArchive";
|
|
@@ -117,6 +117,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
117
117
|
bool hasInit = await CheckInitAndLoginState(method, seesionId);
|
|
118
118
|
if (!hasInit)
|
|
119
119
|
{
|
|
120
|
+
taskSource.TrySetException(new TapException(-1, "Init or login state check failed"));
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
122
123
|
try
|
|
@@ -141,19 +142,16 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
141
142
|
{
|
|
142
143
|
ArchiveData data = response.data.ToObject<ArchiveData>();
|
|
143
144
|
TapCloudSaveTracker.Instance.TrackSuccess(method, seesionId);
|
|
144
|
-
|
|
145
|
+
var archiveData = new ArchiveData()
|
|
145
146
|
{
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
Playtime = metadata.Playtime,
|
|
155
|
-
});
|
|
156
|
-
});
|
|
147
|
+
FileId = data.FileId,
|
|
148
|
+
Uuid = data.Uuid,
|
|
149
|
+
Name = metadata.Name,
|
|
150
|
+
Summary = metadata.Summary,
|
|
151
|
+
Extra = metadata.Extra,
|
|
152
|
+
Playtime = metadata.Playtime,
|
|
153
|
+
};
|
|
154
|
+
taskSource.TrySetResult(archiveData);
|
|
157
155
|
}
|
|
158
156
|
else
|
|
159
157
|
{
|
|
@@ -169,10 +167,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
169
167
|
error.code,
|
|
170
168
|
error.msg ?? ""
|
|
171
169
|
);
|
|
172
|
-
|
|
173
|
-
{
|
|
174
|
-
callback?.OnRequestError(error.code, $"创建存档失败: {error.msg}");
|
|
175
|
-
});
|
|
170
|
+
taskSource.TrySetException(new TapException(error.code, $"创建存档失败: {error.msg}"));
|
|
176
171
|
}
|
|
177
172
|
catch (Exception e)
|
|
178
173
|
{
|
|
@@ -182,10 +177,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
182
177
|
-1,
|
|
183
178
|
"创建存档失败: 数据解析异常"
|
|
184
179
|
);
|
|
185
|
-
|
|
186
|
-
{
|
|
187
|
-
callback?.OnRequestError(-1, "创建存档失败: 数据解析异常");
|
|
188
|
-
});
|
|
180
|
+
taskSource.TrySetException(new TapException(-1, "创建存档失败: 数据解析异常"));
|
|
189
181
|
}
|
|
190
182
|
}
|
|
191
183
|
}
|
|
@@ -193,16 +185,15 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
193
185
|
{
|
|
194
186
|
string msg = $"创建存档失败: {e.Message}";
|
|
195
187
|
TapCloudSaveTracker.Instance.TrackFailure(method, seesionId, -1, msg);
|
|
196
|
-
|
|
197
|
-
{
|
|
198
|
-
callback?.OnRequestError(-1, msg);
|
|
199
|
-
});
|
|
188
|
+
taskSource.TrySetException(new TapException(-1, msg));
|
|
200
189
|
}
|
|
201
190
|
});
|
|
191
|
+
return taskSource.Task;
|
|
202
192
|
}
|
|
203
193
|
|
|
204
|
-
public
|
|
194
|
+
public Task<ArchiveData> DeleteArchive(string archiveUuid)
|
|
205
195
|
{
|
|
196
|
+
var taskSource = new TaskCompletionSource<ArchiveData>();
|
|
206
197
|
CheckPCLaunchState();
|
|
207
198
|
string seesionId = Guid.NewGuid().ToString();
|
|
208
199
|
const string method = "deleteArchive";
|
|
@@ -211,6 +202,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
211
202
|
bool hasInit = await CheckInitAndLoginState(method, seesionId);
|
|
212
203
|
if (!hasInit)
|
|
213
204
|
{
|
|
205
|
+
taskSource.TrySetException(new TapException(-1, "Init or login state check failed"));
|
|
214
206
|
return;
|
|
215
207
|
}
|
|
216
208
|
try
|
|
@@ -222,10 +214,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
222
214
|
{
|
|
223
215
|
ArchiveData archiveData = response.data.ToObject<ArchiveData>();
|
|
224
216
|
TapCloudSaveTracker.Instance.TrackSuccess(method, seesionId);
|
|
225
|
-
|
|
226
|
-
{
|
|
227
|
-
callback?.OnArchiveDeleted(archiveData);
|
|
228
|
-
});
|
|
217
|
+
taskSource.TrySetResult(archiveData);
|
|
229
218
|
}
|
|
230
219
|
else
|
|
231
220
|
{
|
|
@@ -241,10 +230,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
241
230
|
error.code,
|
|
242
231
|
error.msg ?? ""
|
|
243
232
|
);
|
|
244
|
-
|
|
245
|
-
{
|
|
246
|
-
callback?.OnRequestError(error.code, $"删除存档失败: {error.msg}");
|
|
247
|
-
});
|
|
233
|
+
taskSource.TrySetException(new TapException(error.code, $"删除存档失败: {error.msg}"));
|
|
248
234
|
}
|
|
249
235
|
catch (Exception e)
|
|
250
236
|
{
|
|
@@ -254,10 +240,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
254
240
|
-1,
|
|
255
241
|
"删除存档失败: 数据解析异常"
|
|
256
242
|
);
|
|
257
|
-
|
|
258
|
-
{
|
|
259
|
-
callback?.OnRequestError(-1, "删除存档失败: 数据解析异常");
|
|
260
|
-
});
|
|
243
|
+
taskSource.TrySetException(new TapException(-1, "删除存档失败: 数据解析异常"));
|
|
261
244
|
}
|
|
262
245
|
}
|
|
263
246
|
}
|
|
@@ -265,20 +248,18 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
265
248
|
{
|
|
266
249
|
string msg = $"删除失败: {e.Message}";
|
|
267
250
|
TapCloudSaveTracker.Instance.TrackFailure(method, seesionId, -1, msg);
|
|
268
|
-
|
|
269
|
-
{
|
|
270
|
-
callback?.OnRequestError(-1, msg);
|
|
271
|
-
});
|
|
251
|
+
taskSource.TrySetException(new TapException(-1, msg));
|
|
272
252
|
}
|
|
273
253
|
});
|
|
254
|
+
return taskSource.Task;
|
|
274
255
|
}
|
|
275
256
|
|
|
276
|
-
public
|
|
257
|
+
public Task<byte[]> GetArchiveCover(
|
|
277
258
|
string archiveUuid,
|
|
278
|
-
string archiveFileId
|
|
279
|
-
ITapCloudSaveRequestCallback callback
|
|
259
|
+
string archiveFileId
|
|
280
260
|
)
|
|
281
261
|
{
|
|
262
|
+
var taskSource = new TaskCompletionSource<byte[]>();
|
|
282
263
|
CheckPCLaunchState();
|
|
283
264
|
string seesionId = Guid.NewGuid().ToString();
|
|
284
265
|
const string method = "getArchiveCover";
|
|
@@ -287,6 +268,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
287
268
|
bool hasInit = await CheckInitAndLoginState(method, seesionId);
|
|
288
269
|
if (!hasInit)
|
|
289
270
|
{
|
|
271
|
+
taskSource.TrySetException(new TapException(-1, "Init or login state check failed"));
|
|
290
272
|
return;
|
|
291
273
|
}
|
|
292
274
|
try
|
|
@@ -298,10 +280,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
298
280
|
);
|
|
299
281
|
if (coverSize >= 0)
|
|
300
282
|
{
|
|
301
|
-
|
|
302
|
-
{
|
|
303
|
-
callback.OnArchiveCoverResult(result);
|
|
304
|
-
});
|
|
283
|
+
taskSource.TrySetResult(result);
|
|
305
284
|
TapCloudSaveTracker.Instance.TrackSuccess(method, seesionId);
|
|
306
285
|
}
|
|
307
286
|
else
|
|
@@ -322,10 +301,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
322
301
|
error.code,
|
|
323
302
|
error.msg ?? ""
|
|
324
303
|
);
|
|
325
|
-
|
|
326
|
-
{
|
|
327
|
-
callback?.OnRequestError(error.code, $"获取封面失败: {error.msg}");
|
|
328
|
-
});
|
|
304
|
+
taskSource.TrySetException(new TapException(error.code, $"获取封面失败: {error.msg}"));
|
|
329
305
|
}
|
|
330
306
|
catch (Exception e)
|
|
331
307
|
{
|
|
@@ -335,10 +311,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
335
311
|
-1,
|
|
336
312
|
"获取封面失败: 数据解析异常"
|
|
337
313
|
);
|
|
338
|
-
|
|
339
|
-
{
|
|
340
|
-
callback?.OnRequestError(-1, "获取封面失败: 数据解析异常");
|
|
341
|
-
});
|
|
314
|
+
taskSource.TrySetException(new TapException(-1, "获取封面失败: 数据解析异常"));
|
|
342
315
|
}
|
|
343
316
|
}
|
|
344
317
|
}
|
|
@@ -346,20 +319,18 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
346
319
|
{
|
|
347
320
|
string msg = $"获取封面失败: {e.Message}";
|
|
348
321
|
TapCloudSaveTracker.Instance.TrackFailure(method, seesionId, -1, msg);
|
|
349
|
-
|
|
350
|
-
{
|
|
351
|
-
callback?.OnRequestError(-1, msg);
|
|
352
|
-
});
|
|
322
|
+
taskSource.TrySetException(new TapException(-1, msg));
|
|
353
323
|
}
|
|
354
324
|
});
|
|
325
|
+
return taskSource.Task;
|
|
355
326
|
}
|
|
356
327
|
|
|
357
|
-
public
|
|
328
|
+
public Task<byte[]> GetArchiveData(
|
|
358
329
|
string archiveUuid,
|
|
359
|
-
string archiveFileId
|
|
360
|
-
ITapCloudSaveRequestCallback callback
|
|
330
|
+
string archiveFileId
|
|
361
331
|
)
|
|
362
332
|
{
|
|
333
|
+
var taskSource = new TaskCompletionSource<byte[]>();
|
|
363
334
|
CheckPCLaunchState();
|
|
364
335
|
string seesionId = Guid.NewGuid().ToString();
|
|
365
336
|
const string method = "getArchiveData";
|
|
@@ -368,6 +339,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
368
339
|
bool hasInit = await CheckInitAndLoginState(method, seesionId);
|
|
369
340
|
if (!hasInit)
|
|
370
341
|
{
|
|
342
|
+
taskSource.TrySetException(new TapException(-1, "Init or login state check failed"));
|
|
371
343
|
return;
|
|
372
344
|
}
|
|
373
345
|
try
|
|
@@ -379,10 +351,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
379
351
|
);
|
|
380
352
|
if (fileSize >= 0)
|
|
381
353
|
{
|
|
382
|
-
|
|
383
|
-
{
|
|
384
|
-
callback.OnArchiveDataResult(result);
|
|
385
|
-
});
|
|
354
|
+
taskSource.TrySetResult(result);
|
|
386
355
|
TapCloudSaveTracker.Instance.TrackSuccess(method, seesionId);
|
|
387
356
|
}
|
|
388
357
|
else
|
|
@@ -403,10 +372,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
403
372
|
error.code,
|
|
404
373
|
error.msg ?? ""
|
|
405
374
|
);
|
|
406
|
-
|
|
407
|
-
{
|
|
408
|
-
callback?.OnRequestError(error.code, $"获取存档失败: {error.msg}");
|
|
409
|
-
});
|
|
375
|
+
taskSource.TrySetException(new TapException(error.code, $"获取存档失败: {error.msg}"));
|
|
410
376
|
}
|
|
411
377
|
catch (Exception e)
|
|
412
378
|
{
|
|
@@ -416,10 +382,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
416
382
|
-1,
|
|
417
383
|
"获取存档失败: 数据解析异常"
|
|
418
384
|
);
|
|
419
|
-
|
|
420
|
-
{
|
|
421
|
-
callback?.OnRequestError(-1, "获取存档失败: 数据解析异常");
|
|
422
|
-
});
|
|
385
|
+
taskSource.TrySetException(new TapException(-1, "获取存档失败: 数据解析异常"));
|
|
423
386
|
}
|
|
424
387
|
}
|
|
425
388
|
}
|
|
@@ -427,16 +390,15 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
427
390
|
{
|
|
428
391
|
string msg = $"获取存档失败: {e.Message}";
|
|
429
392
|
TapCloudSaveTracker.Instance.TrackFailure(method, seesionId, -1, msg);
|
|
430
|
-
|
|
431
|
-
{
|
|
432
|
-
callback?.OnRequestError(-1, msg);
|
|
433
|
-
});
|
|
393
|
+
taskSource.TrySetException(new TapException(-1, msg));
|
|
434
394
|
}
|
|
435
395
|
});
|
|
396
|
+
return taskSource.Task;
|
|
436
397
|
}
|
|
437
398
|
|
|
438
|
-
public
|
|
399
|
+
public Task<List<ArchiveData>> GetArchiveList()
|
|
439
400
|
{
|
|
401
|
+
var taskSource = new TaskCompletionSource<List<ArchiveData>>();
|
|
440
402
|
CheckPCLaunchState();
|
|
441
403
|
string seesionId = Guid.NewGuid().ToString();
|
|
442
404
|
const string method = "getArchiveList";
|
|
@@ -445,6 +407,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
445
407
|
bool hasInit = await CheckInitAndLoginState(method, seesionId);
|
|
446
408
|
if (!hasInit)
|
|
447
409
|
{
|
|
410
|
+
taskSource.TrySetException(new TapException(-1, "Init or login state check failed"));
|
|
448
411
|
return;
|
|
449
412
|
}
|
|
450
413
|
try
|
|
@@ -457,10 +420,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
457
420
|
TapCloudSaveArchiveListResponse archiveDatas =
|
|
458
421
|
response.data.ToObject<TapCloudSaveArchiveListResponse>();
|
|
459
422
|
TapCloudSaveTracker.Instance.TrackSuccess(method, seesionId);
|
|
460
|
-
|
|
461
|
-
{
|
|
462
|
-
callback?.OnArchiveListResult(archiveDatas.saves);
|
|
463
|
-
});
|
|
423
|
+
taskSource.TrySetResult(archiveDatas.saves);
|
|
464
424
|
}
|
|
465
425
|
else
|
|
466
426
|
{
|
|
@@ -476,13 +436,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
476
436
|
error.code,
|
|
477
437
|
error.msg ?? ""
|
|
478
438
|
);
|
|
479
|
-
|
|
480
|
-
{
|
|
481
|
-
callback?.OnRequestError(
|
|
482
|
-
error.code,
|
|
483
|
-
$"获取存档列表失败: {error.msg}"
|
|
484
|
-
);
|
|
485
|
-
});
|
|
439
|
+
taskSource.TrySetException(new TapException(error.code, $"获取存档列表失败: {error.msg}"));
|
|
486
440
|
}
|
|
487
441
|
catch (Exception e)
|
|
488
442
|
{
|
|
@@ -492,10 +446,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
492
446
|
-1,
|
|
493
447
|
"获取存档列表失败: 数据解析异常"
|
|
494
448
|
);
|
|
495
|
-
|
|
496
|
-
{
|
|
497
|
-
callback?.OnRequestError(-1, "获取存档列表失败: 数据解析异常");
|
|
498
|
-
});
|
|
449
|
+
taskSource.TrySetException(new TapException(-1, "获取存档列表失败: 数据解析异常"));
|
|
499
450
|
}
|
|
500
451
|
}
|
|
501
452
|
}
|
|
@@ -503,12 +454,10 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
503
454
|
{
|
|
504
455
|
string msg = $"获取存档列表失败: {e.Message}";
|
|
505
456
|
TapCloudSaveTracker.Instance.TrackFailure(method, seesionId, -1, msg);
|
|
506
|
-
|
|
507
|
-
{
|
|
508
|
-
callback?.OnRequestError(-1, msg);
|
|
509
|
-
});
|
|
457
|
+
taskSource.TrySetException(new TapException(-1, msg));
|
|
510
458
|
}
|
|
511
459
|
});
|
|
460
|
+
return taskSource.Task;
|
|
512
461
|
}
|
|
513
462
|
|
|
514
463
|
public void RegisterCloudSaveCallback(ITapCloudSaveCallback callback)
|
|
@@ -536,14 +485,14 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
536
485
|
}
|
|
537
486
|
}
|
|
538
487
|
|
|
539
|
-
public
|
|
488
|
+
public Task<ArchiveData> UpdateArchive(
|
|
540
489
|
string archiveUuid,
|
|
541
490
|
ArchiveMetadata metadata,
|
|
542
491
|
string archiveFilePath,
|
|
543
|
-
string archiveCoverPath
|
|
544
|
-
ITapCloudSaveRequestCallback callback
|
|
492
|
+
string archiveCoverPath
|
|
545
493
|
)
|
|
546
494
|
{
|
|
495
|
+
var taskSource = new TaskCompletionSource<ArchiveData>();
|
|
547
496
|
CheckPCLaunchState();
|
|
548
497
|
string seesionId = Guid.NewGuid().ToString();
|
|
549
498
|
const string method = "updateArchive";
|
|
@@ -552,6 +501,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
552
501
|
bool hasInit = await CheckInitAndLoginState(method, seesionId);
|
|
553
502
|
if (!hasInit)
|
|
554
503
|
{
|
|
504
|
+
taskSource.TrySetException(new TapException(-1, "Init or login state check failed"));
|
|
555
505
|
return;
|
|
556
506
|
}
|
|
557
507
|
try
|
|
@@ -577,10 +527,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
577
527
|
{
|
|
578
528
|
ArchiveData data = response.data.ToObject<ArchiveData>();
|
|
579
529
|
TapCloudSaveTracker.Instance.TrackSuccess(method, seesionId);
|
|
580
|
-
|
|
581
|
-
{
|
|
582
|
-
callback?.OnArchiveUpdated(data);
|
|
583
|
-
});
|
|
530
|
+
taskSource.TrySetResult(data);
|
|
584
531
|
}
|
|
585
532
|
else
|
|
586
533
|
{
|
|
@@ -596,10 +543,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
596
543
|
error.code,
|
|
597
544
|
error.msg ?? ""
|
|
598
545
|
);
|
|
599
|
-
|
|
600
|
-
{
|
|
601
|
-
callback?.OnRequestError(error.code, $"更新存档失败: {error.msg}");
|
|
602
|
-
});
|
|
546
|
+
taskSource.TrySetException(new TapException(error.code, $"更新存档失败: {error.msg}"));
|
|
603
547
|
}
|
|
604
548
|
catch (Exception e)
|
|
605
549
|
{
|
|
@@ -609,10 +553,7 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
609
553
|
-1,
|
|
610
554
|
"更新存档失败: 数据解析异常"
|
|
611
555
|
);
|
|
612
|
-
|
|
613
|
-
{
|
|
614
|
-
callback?.OnRequestError(-1, "更新存档失败: 数据解析异常");
|
|
615
|
-
});
|
|
556
|
+
taskSource.TrySetException(new TapException(-1, "更新存档失败: 数据解析异常"));
|
|
616
557
|
}
|
|
617
558
|
}
|
|
618
559
|
}
|
|
@@ -620,12 +561,10 @@ namespace TapSDK.CloudSave.Standalone
|
|
|
620
561
|
{
|
|
621
562
|
string msg = $"更新存档失败: {e.Message}";
|
|
622
563
|
TapCloudSaveTracker.Instance.TrackFailure(method, seesionId, -1, msg);
|
|
623
|
-
|
|
624
|
-
{
|
|
625
|
-
callback?.OnRequestError(-1, msg);
|
|
626
|
-
});
|
|
564
|
+
taskSource.TrySetException(new TapException(-1, msg));
|
|
627
565
|
}
|
|
628
566
|
});
|
|
567
|
+
return taskSource.Task;
|
|
629
568
|
}
|
|
630
569
|
|
|
631
570
|
private async Task<bool> CheckInitAndLoginState(string method, string sessionId)
|
package/package.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"name": "com.taptap.sdk.cloudsave",
|
|
3
3
|
"displayName": "TapTapSDK CloudSave",
|
|
4
4
|
"description": "TapTapSDK CloudSave",
|
|
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
|
}
|