com.taptap.sdk.cloudsave 4.8.0-beta.1 → 4.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/Mobile/Editor/NativeDependencies.xml +8 -2
  2. package/Mobile/Editor/TapCloudSaveMobileProcessBuild.cs +1 -0
  3. package/Mobile/Runtime/TapCloudSaveBridge.cs +168 -57
  4. package/Runtime/Internal/ITapCloudSaveBridge.cs +14 -9
  5. package/Runtime/Internal/TapCloudSaveInitTask.cs +2 -0
  6. package/Runtime/Internal/TapTapCloudSaveInternal.cs +22 -29
  7. package/Runtime/Public/TapTapCloudSave.cs +18 -29
  8. package/Standalone/Editor/TapCloudSaveStandaloneProcessBuild.cs +26 -0
  9. package/Standalone/Editor/TapCloudSaveStandaloneProcessBuild.cs.meta +11 -0
  10. package/Standalone/Editor/TapSDK.CloudSave.Standalone.Editor.asmdef +17 -0
  11. package/Standalone/Editor/TapSDK.CloudSave.Standalone.Editor.asmdef.meta +7 -0
  12. package/Standalone/Editor.meta +8 -0
  13. package/Standalone/Plugins/x86_64/cloudsave_sdk.dll +0 -0
  14. package/Standalone/Plugins/x86_64/cloudsave_sdk.dll.meta +80 -0
  15. package/Standalone/Plugins/x86_64.meta +8 -0
  16. package/Standalone/Plugins.meta +8 -0
  17. package/Standalone/Runtime/Internal/TapCloudSaveArchiveListResponse.cs +11 -0
  18. package/Standalone/Runtime/Internal/TapCloudSaveArchiveListResponse.cs.meta +11 -0
  19. package/Standalone/Runtime/Internal/TapCloudSaveBaseResponse.cs +29 -0
  20. package/Standalone/Runtime/Internal/TapCloudSaveBaseResponse.cs.meta +11 -0
  21. package/Standalone/Runtime/Internal/TapCloudSaveTracker.cs +101 -0
  22. package/Standalone/Runtime/Internal/TapCloudSaveTracker.cs.meta +11 -0
  23. package/Standalone/Runtime/Internal/TapCloudSaveWrapper.cs +518 -0
  24. package/Standalone/Runtime/Internal/TapCloudSaveWrapper.cs.meta +11 -0
  25. package/Standalone/Runtime/Internal.meta +8 -0
  26. package/Standalone/Runtime/TapCloudSaveResultCode.cs +9 -0
  27. package/Standalone/Runtime/TapCloudSaveResultCode.cs.meta +11 -0
  28. package/Standalone/Runtime/TapCloudSaveStandalone.cs +672 -0
  29. package/Standalone/Runtime/TapCloudSaveStandalone.cs.meta +11 -0
  30. package/Standalone/Runtime.meta +8 -0
  31. package/Standalone/TapSDK.CloudSave.Standalone.Runtime.asmdef +22 -0
  32. package/Standalone/TapSDK.CloudSave.Standalone.Runtime.asmdef.meta +7 -0
  33. package/Standalone.meta +8 -0
  34. package/link.xml.meta +1 -1
  35. package/package.json +10 -10
@@ -1,9 +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.0-beta.1"/>
7
+ <androidPackage spec="com.taptap.sdk:tap-cloudsave-unity:4.8.1-beta.7"/>
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="TapTapCloudSaveSDK" version="4.8.1-beta.7"/>
14
+ </iosPods>
9
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,11 +1,19 @@
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
  {
11
+ public class ErrorResponse
12
+ {
13
+ [JsonProperty("errorCode")] public int ErrorCode { get; set; }
14
+ [JsonProperty("errorMessage")] public string ErrorMessage { get; set; }
15
+ }
16
+
9
17
  public class TapCloudSaveBridge : ITapCloudSaveBridge
10
18
  {
11
19
  public static string TAP_CLOUDSAVE_SERVICE = "BridgeCloudSaveService";
@@ -19,8 +27,14 @@ namespace TapSDK.CloudSave.Mobile
19
27
  EngineBridge.GetInstance().Register(TDS_CLOUDSAVE_SERVICE_CLZ, TDS_CLOUDSAVE_SERVICE_IMPL);
20
28
  }
21
29
 
30
+ public void Init(TapTapSdkOptions options)
31
+ {
32
+ // 原生由原生内部实现
33
+ }
34
+
22
35
  public void RegisterCloudSaveCallback(ITapCloudSaveCallback callback)
23
36
  {
37
+ TapLog.Log("[TapCloudSaveBridge] RegisterCloudSaveCallback called (UNCHANGED callback pattern)");
24
38
  EngineBridge.GetInstance().CallHandler(new Command.Builder()
25
39
  .Service(TAP_CLOUDSAVE_SERVICE)
26
40
  .Method("registerCloudSaveCallback")
@@ -37,7 +51,7 @@ namespace TapSDK.CloudSave.Mobile
37
51
  callback.OnResult(-1);
38
52
  return;
39
53
  }
40
-
54
+
41
55
  var result = JsonConvert.DeserializeObject<TapEngineBridgeResult>(response.content);
42
56
  if (result != null && result.code == TapEngineBridgeResult.RESULT_SUCCESS)
43
57
  {
@@ -63,25 +77,26 @@ namespace TapSDK.CloudSave.Mobile
63
77
  });
64
78
  }
65
79
 
66
- public void CreateArchive(string metadata, string archiveFilePath, string archiveCoverPath, ITapCloudSaveRequestCallback callback)
80
+ public Task<ArchiveData> CreateArchive(ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath)
67
81
  {
82
+ TapLog.Log("[TapCloudSaveBridge] CreateArchive called with Task<ArchiveData> return type (NEW API)");
83
+ var taskSource = new TaskCompletionSource<ArchiveData>();
68
84
  EngineBridge.GetInstance().CallHandler(new Command.Builder()
69
85
  .Service(TAP_CLOUDSAVE_SERVICE)
70
86
  .Method("createArchive")
71
- .Args("archiveMetadata", metadata)
87
+ .Args("archiveMetadata", JsonConvert.SerializeObject(metadata))
72
88
  .Args("archiveFilePath", archiveFilePath)
73
89
  .Args("archiveCoverPath", archiveCoverPath)
74
90
  .Callback(true)
75
91
  .OnceTime(true)
76
- .CommandBuilder(), (response) =>
92
+ .CommandBuilder(),
93
+ response =>
77
94
  {
78
- if (callback == null) return;
79
-
80
95
  try
81
96
  {
82
97
  if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
83
98
  {
84
- callback.OnRequestError(-1, "Failed to create archive: code="+response.code + "content="+response.content);
99
+ taskSource.TrySetException(new TapException(-1, "Failed to create archive: code="+response.code + " content="+response.content));
85
100
  return;
86
101
  }
87
102
 
@@ -91,45 +106,61 @@ namespace TapSDK.CloudSave.Mobile
91
106
  var archive = JsonConvert.DeserializeObject<ArchiveData>(result.content);
92
107
  if (archive != null)
93
108
  {
94
- callback.OnArchiveCreated(archive);
109
+ taskSource.TrySetResult(archive);
95
110
  }
96
111
  else
97
112
  {
98
- callback.OnRequestError(-1, "json convert failed: content="+result.content);
113
+ taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
99
114
  }
100
115
  }
101
116
  else
102
117
  {
103
- callback.OnRequestError(-1, "Failed to create archive: content="+response.content);
118
+ try
119
+ {
120
+ var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
121
+ if (errorResponse != null)
122
+ {
123
+ taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
124
+ }
125
+ else
126
+ {
127
+ taskSource.TrySetException(new TapException(-1, "Failed to create archive: content="+response.content));
128
+ }
129
+ }
130
+ catch (Exception e)
131
+ {
132
+ taskSource.TrySetException(new TapException(-1, "Failed to create archive: content="+response.content));
133
+ }
104
134
  }
105
135
  }
106
136
  catch (Exception e)
107
137
  {
108
- callback.OnRequestError(-1, "Failed to create archive: error=" + e.Message + ", content=" + response.content);
138
+ taskSource.TrySetException(new TapException(-1, "Failed to create archive: error=" + e.Message + ", content=" + response.content));
109
139
  }
110
140
  });
141
+ return taskSource.Task;
111
142
  }
112
143
 
113
- public void UpdateArchive(string archiveUuid, string metadata, string archiveFilePath, string archiveCoverPath, ITapCloudSaveRequestCallback callback)
144
+ public Task<ArchiveData> UpdateArchive(string archiveUuid, ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath)
114
145
  {
146
+ TapLog.Log("[TapCloudSaveBridge] UpdateArchive called with Task<ArchiveData> return type (NEW API)");
147
+ var taskSource = new TaskCompletionSource<ArchiveData>();
115
148
  EngineBridge.GetInstance().CallHandler(new Command.Builder()
116
149
  .Service(TAP_CLOUDSAVE_SERVICE)
117
150
  .Method("updateArchive")
118
- .Args("archiveUUID", archiveUuid)
119
- .Args("archiveMetadata", metadata)
120
- .Args("archiveFilePath", archiveFilePath)
121
- .Args("archiveCoverPath", archiveCoverPath)
151
+ .Args("archiveUUIDForUpdate", archiveUuid)
152
+ .Args("archiveMetadataForUpdate", JsonConvert.SerializeObject(metadata))
153
+ .Args("archiveFilePathForUpdate", archiveFilePath)
154
+ .Args("archiveCoverPathForUpdate", archiveCoverPath)
122
155
  .Callback(true)
123
156
  .OnceTime(true)
124
157
  .CommandBuilder(), (response) =>
125
158
  {
126
- if (callback == null) return;
127
-
128
159
  try
129
160
  {
130
161
  if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
131
162
  {
132
- callback.OnRequestError(-1, "Failed to update archive: code="+response.code + "content="+response.content);
163
+ taskSource.TrySetException(new TapException(-1, "Failed to update archive: code="+response.code + " content="+response.content));
133
164
  return;
134
165
  }
135
166
 
@@ -139,27 +170,45 @@ namespace TapSDK.CloudSave.Mobile
139
170
  var archive = JsonConvert.DeserializeObject<ArchiveData>(result.content);
140
171
  if (archive != null)
141
172
  {
142
- callback.OnArchiveUpdated(archive);
173
+ taskSource.TrySetResult(archive);
143
174
  }
144
175
  else
145
176
  {
146
- callback.OnRequestError(-1, "json convert failed: content="+result.content);
177
+ taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
147
178
  }
148
179
  }
149
180
  else
150
181
  {
151
- callback.OnRequestError(-1, "Failed to update archive: content="+response.content);
182
+ try
183
+ {
184
+ var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
185
+ if (errorResponse != null)
186
+ {
187
+ taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
188
+ }
189
+ else
190
+ {
191
+ taskSource.TrySetException(new TapException(-1, "Failed to update archive: content="+response.content));
192
+ }
193
+ }
194
+ catch (Exception e)
195
+ {
196
+ taskSource.TrySetException(new TapException(-1, "Failed to update archive: content="+response.content));
197
+ }
152
198
  }
153
199
  }
154
200
  catch (Exception e)
155
201
  {
156
- callback.OnRequestError(-1, "Failed to update archive: error=" + e.Message + ", content=" + response.content);
202
+ taskSource.TrySetException(new TapException(-1, "Failed to update archive: error=" + e.Message + ", content=" + response.content));
157
203
  }
158
204
  });
205
+ return taskSource.Task;
159
206
  }
160
207
 
161
- public void DeleteArchive(string archiveUuid, ITapCloudSaveRequestCallback callback)
208
+ public Task<ArchiveData> DeleteArchive(string archiveUuid)
162
209
  {
210
+ TapLog.Log("[TapCloudSaveBridge] DeleteArchive called with Task<ArchiveData> return type (NEW API)");
211
+ var taskSource = new TaskCompletionSource<ArchiveData>();
163
212
  EngineBridge.GetInstance().CallHandler(new Command.Builder()
164
213
  .Service(TAP_CLOUDSAVE_SERVICE)
165
214
  .Method("deleteArchive")
@@ -168,13 +217,11 @@ namespace TapSDK.CloudSave.Mobile
168
217
  .OnceTime(true)
169
218
  .CommandBuilder(), (response) =>
170
219
  {
171
- if (callback == null) return;
172
-
173
220
  try
174
221
  {
175
222
  if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
176
223
  {
177
- callback.OnRequestError(-1, "Failed to delete archive: code="+response.code + "content="+response.content);
224
+ taskSource.TrySetException(new TapException(-1, "Failed to delete archive: code="+response.code + " content="+response.content));
178
225
  return;
179
226
  }
180
227
 
@@ -184,27 +231,45 @@ namespace TapSDK.CloudSave.Mobile
184
231
  var archive = JsonConvert.DeserializeObject<ArchiveData>(result.content);
185
232
  if (archive != null)
186
233
  {
187
- callback.OnArchiveDeleted(archive);
234
+ taskSource.TrySetResult(archive);
188
235
  }
189
236
  else
190
237
  {
191
- callback.OnRequestError(-1, "json convert failed: content="+response.content);
238
+ taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
192
239
  }
193
240
  }
194
241
  else
195
242
  {
196
- callback.OnRequestError(-1, "Failed to delete archive: content="+response.content);
243
+ try
244
+ {
245
+ var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
246
+ if (errorResponse != null)
247
+ {
248
+ taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
249
+ }
250
+ else
251
+ {
252
+ taskSource.TrySetException(new TapException(-1, "Failed to delete archive: content="+response.content));
253
+ }
254
+ }
255
+ catch (Exception e)
256
+ {
257
+ taskSource.TrySetException(new TapException(-1, "Failed to delete archive: content="+response.content));
258
+ }
197
259
  }
198
260
  }
199
261
  catch (Exception e)
200
262
  {
201
- callback.OnRequestError(-1, "Failed to delete archive: error=" + e.Message + ", content=" + response.content);
263
+ taskSource.TrySetException(new TapException(-1, "Failed to delete archive: error=" + e.Message + ", content=" + response.content));
202
264
  }
203
265
  });
266
+ return taskSource.Task;
204
267
  }
205
268
 
206
- public void GetArchiveList(ITapCloudSaveRequestCallback callback)
269
+ public Task<List<ArchiveData>> GetArchiveList()
207
270
  {
271
+ TapLog.Log("[TapCloudSaveBridge] GetArchiveList called with Task<List<ArchiveData>> return type (NEW API)");
272
+ var taskSource = new TaskCompletionSource<List<ArchiveData>>();
208
273
  EngineBridge.GetInstance().CallHandler(new Command.Builder()
209
274
  .Service(TAP_CLOUDSAVE_SERVICE)
210
275
  .Method("getArchiveList")
@@ -212,13 +277,11 @@ namespace TapSDK.CloudSave.Mobile
212
277
  .OnceTime(true)
213
278
  .CommandBuilder(), (response) =>
214
279
  {
215
- if (callback == null) return;
216
-
217
280
  try
218
281
  {
219
282
  if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
220
283
  {
221
- callback.OnRequestError(-1, "Failed to get archive list: code="+response.code + "content="+response.content);
284
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive list: code="+response.code + " content="+response.content));
222
285
  return;
223
286
  }
224
287
 
@@ -228,27 +291,45 @@ namespace TapSDK.CloudSave.Mobile
228
291
  var archiveList = JsonConvert.DeserializeObject<List<ArchiveData>>(result.content);
229
292
  if (archiveList != null)
230
293
  {
231
- callback.OnArchiveListResult(archiveList);
294
+ taskSource.TrySetResult(archiveList);
232
295
  }
233
296
  else
234
297
  {
235
- callback.OnRequestError(-1, "json convert failed: content="+response.content);
298
+ taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
236
299
  }
237
300
  }
238
301
  else
239
302
  {
240
- callback.OnRequestError(-1, "Failed to get archive list: content="+response.content);
303
+ try
304
+ {
305
+ var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
306
+ if (errorResponse != null)
307
+ {
308
+ taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
309
+ }
310
+ else
311
+ {
312
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive list: content="+response.content));
313
+ }
314
+ }
315
+ catch (Exception e)
316
+ {
317
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive list: content="+response.content));
318
+ }
241
319
  }
242
320
  }
243
321
  catch (Exception e)
244
322
  {
245
- callback.OnRequestError(-1, "Failed to get archive list: error=" + e.Message + ", content=" + response.content);
323
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive list: error=" + e.Message + ", content=" + response.content));
246
324
  }
247
325
  });
326
+ return taskSource.Task;
248
327
  }
249
328
 
250
- public void GetArchiveData(string archiveUuid, string archiveFileId, ITapCloudSaveRequestCallback callback)
329
+ public Task<byte[]> GetArchiveData(string archiveUuid, string archiveFileId)
251
330
  {
331
+ TapLog.Log("[TapCloudSaveBridge] GetArchiveData called with Task<byte[]> return type (NEW API)");
332
+ var taskSource = new TaskCompletionSource<byte[]>();
252
333
  EngineBridge.GetInstance().CallHandler(new Command.Builder()
253
334
  .Service(TAP_CLOUDSAVE_SERVICE)
254
335
  .Method("getArchiveData")
@@ -258,13 +339,11 @@ namespace TapSDK.CloudSave.Mobile
258
339
  .OnceTime(true)
259
340
  .CommandBuilder(), (response) =>
260
341
  {
261
- if (callback == null) return;
262
-
263
342
  try
264
343
  {
265
344
  if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
266
345
  {
267
- callback.OnRequestError(-1, "Failed to get archive data: code=" + response.code + "content="+response.content);
346
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive data: code=" + response.code + " content="+response.content));
268
347
  return;
269
348
  }
270
349
 
@@ -274,43 +353,59 @@ namespace TapSDK.CloudSave.Mobile
274
353
  var archiveData = Convert.FromBase64String(result.content);
275
354
  if (archiveData != null)
276
355
  {
277
- callback.OnArchiveDataResult(archiveData);
356
+ taskSource.TrySetResult(archiveData);
278
357
  }
279
358
  else
280
359
  {
281
- callback.OnRequestError(-1, "json convert failed: content="+response.content);
360
+ taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
282
361
  }
283
362
  }
284
363
  else
285
364
  {
286
- callback.OnRequestError(-1, "Failed to convert base64 data: content="+response.content);
365
+ try
366
+ {
367
+ var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
368
+ if (errorResponse != null)
369
+ {
370
+ taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
371
+ }
372
+ else
373
+ {
374
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive data: content="+response.content));
375
+ }
376
+ }
377
+ catch (Exception e)
378
+ {
379
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive data: content="+response.content));
380
+ }
287
381
  }
288
382
  }
289
383
  catch (Exception e)
290
384
  {
291
- callback.OnRequestError(-1, "Failed to get archive data: error=" + e.Message + ", content=" + response.content);
385
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive data: error=" + e.Message + ", content=" + response.content));
292
386
  }
293
387
  });
388
+ return taskSource.Task;
294
389
  }
295
390
 
296
- public void GetArchiveCover(string archiveUuid, string archiveFileId, ITapCloudSaveRequestCallback callback)
391
+ public Task<byte[]> GetArchiveCover(string archiveUuid, string archiveFileId)
297
392
  {
393
+ TapLog.Log("[TapCloudSaveBridge] GetArchiveCover called with Task<byte[]> return type (NEW API)");
394
+ var taskSource = new TaskCompletionSource<byte[]>();
298
395
  EngineBridge.GetInstance().CallHandler(new Command.Builder()
299
396
  .Service(TAP_CLOUDSAVE_SERVICE)
300
397
  .Method("getArchiveCover")
301
- .Args("archiveUUID", archiveUuid)
302
- .Args("archiveFileID", archiveFileId)
398
+ .Args("archiveUUIDForCover", archiveUuid)
399
+ .Args("archiveFileIDForCover", archiveFileId)
303
400
  .Callback(true)
304
401
  .OnceTime(true)
305
402
  .CommandBuilder(), (response) =>
306
403
  {
307
- if (callback == null) return;
308
-
309
404
  try
310
405
  {
311
406
  if (response.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(response.content))
312
407
  {
313
- callback.OnRequestError(-1, "Failed to get archive cover: code="+response.code + "content="+response.content);
408
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive cover: code="+response.code + " content="+response.content));
314
409
  return;
315
410
  }
316
411
 
@@ -320,23 +415,39 @@ namespace TapSDK.CloudSave.Mobile
320
415
  var coverData = Convert.FromBase64String(result.content);
321
416
  if (coverData != null)
322
417
  {
323
- callback.OnArchiveCoverResult(coverData);
418
+ taskSource.TrySetResult(coverData);
324
419
  }
325
420
  else
326
421
  {
327
- callback.OnRequestError(-1, "json convert failed: content="+response.content);
422
+ taskSource.TrySetException(new TapException(-1, "json convert failed: content="+result.content));
328
423
  }
329
424
  }
330
425
  else
331
426
  {
332
- callback.OnRequestError(-1, "Failed to convert base64 data: content="+response.content);
427
+ try
428
+ {
429
+ var errorResponse = JsonConvert.DeserializeObject<ErrorResponse>(result.content);
430
+ if (errorResponse != null)
431
+ {
432
+ taskSource.TrySetException(new TapException(errorResponse.ErrorCode, errorResponse.ErrorMessage));
433
+ }
434
+ else
435
+ {
436
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive cover: content="+response.content));
437
+ }
438
+ }
439
+ catch (Exception e)
440
+ {
441
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive cover: content="+response.content));
442
+ }
333
443
  }
334
444
  }
335
445
  catch (Exception e)
336
446
  {
337
- callback.OnRequestError(-1, "Failed to get archive cover: error=" + e.Message + ", content=" + response.content);
447
+ taskSource.TrySetException(new TapException(-1, "Failed to get archive cover: error=" + e.Message + ", content=" + response.content));
338
448
  }
339
449
  });
450
+ return taskSource.Task;
340
451
  }
341
452
  }
342
453
  }
@@ -1,18 +1,23 @@
1
- namespace TapSDK.CloudSave.Internal
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Threading.Tasks;
4
+ using TapSDK.Core;
5
+
6
+ namespace TapSDK.CloudSave.Internal
2
7
  {
3
8
  public interface ITapCloudSaveBridge
4
9
  {
10
+ void Init(TapTapSdkOptions options);
11
+
5
12
  void RegisterCloudSaveCallback(ITapCloudSaveCallback callback);
6
13
 
7
- void CreateArchive(string metadata, string archiveFilePath, string archiveCoverPath,
8
- ITapCloudSaveRequestCallback callback);
14
+ Task<ArchiveData> CreateArchive(ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath);
9
15
 
10
- void UpdateArchive(string archiveUuid, string metadata, string archiveFilePath, string archiveCoverPath,
11
- ITapCloudSaveRequestCallback callback);
16
+ Task<ArchiveData> UpdateArchive(string archiveUuid, ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath);
12
17
 
13
- void DeleteArchive(string archiveUuid, ITapCloudSaveRequestCallback callback);
14
- void GetArchiveList(ITapCloudSaveRequestCallback callback);
15
- void GetArchiveData(string archiveUuid, string archiveFileId, ITapCloudSaveRequestCallback callback);
16
- void GetArchiveCover(string archiveUuid, string archiveFileId, ITapCloudSaveRequestCallback callback);
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);
17
22
  }
18
23
  }
@@ -9,10 +9,12 @@ namespace TapSDK.CloudSave.Internal.Init
9
9
 
10
10
  public void Init(TapTapSdkOptions coreOption)
11
11
  {
12
+ TapTapCloudSaveInternal.Init(coreOption);
12
13
  }
13
14
 
14
15
  public void Init(TapTapSdkOptions coreOption, TapTapSdkBaseOptions[] otherOptions)
15
16
  {
17
+ TapTapCloudSaveInternal.Init(coreOption);
16
18
  }
17
19
  }
18
20
  }
@@ -1,3 +1,7 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Threading.Tasks;
4
+ using TapSDK.Core;
1
5
  using TapSDK.Core.Internal.Utils;
2
6
 
3
7
  namespace TapSDK.CloudSave.Internal
@@ -11,44 +15,33 @@ namespace TapSDK.CloudSave.Internal
11
15
  Bridge = BridgeUtils.CreateBridgeImplementation(typeof(ITapCloudSaveBridge), "TapSDK.CloudSave")
12
16
  as ITapCloudSaveBridge;
13
17
  }
14
-
15
- internal static void RegisterCloudSaveCallback(ITapCloudSaveCallback callback)
16
- {
17
- Bridge?.RegisterCloudSaveCallback(callback);
18
- }
19
18
 
20
- internal static void CreateArchive(string metadata, string archiveFilePath, string archiveCoverPath,
21
- ITapCloudSaveRequestCallback callback)
19
+ internal static void Init(TapTapSdkOptions options)
22
20
  {
23
- Bridge?.CreateArchive(metadata, archiveFilePath, archiveCoverPath, callback);
21
+ Bridge?.Init(options);
24
22
  }
25
23
 
26
- internal static void UpdateArchive(string archiveUuid, string metadata, string archiveFilePath,
27
- string archiveCoverPath, ITapCloudSaveRequestCallback callback)
24
+ internal static void RegisterCloudSaveCallback(ITapCloudSaveCallback callback)
28
25
  {
29
- Bridge?.UpdateArchive(archiveUuid, metadata, archiveFilePath, archiveCoverPath, callback);
26
+ Bridge?.RegisterCloudSaveCallback(callback);
30
27
  }
31
28
 
32
- internal static void DeleteArchive(string archiveUuid, ITapCloudSaveRequestCallback callback)
33
- {
34
- Bridge?.DeleteArchive(archiveUuid, callback);
35
- }
29
+ internal static Task<ArchiveData> CreateArchive(ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath) =>
30
+ Bridge?.CreateArchive(metadata, archiveFilePath, archiveCoverPath);
36
31
 
37
- internal static void GetArchiveList(ITapCloudSaveRequestCallback callback)
38
- {
39
- Bridge?.GetArchiveList(callback);
40
- }
32
+ internal static Task<ArchiveData> UpdateArchive(string archiveUuid, ArchiveMetadata metadata, string archiveFilePath, string archiveCoverPath) =>
33
+ Bridge?.UpdateArchive(archiveUuid, metadata, archiveFilePath, archiveCoverPath);
41
34
 
42
- internal static void GetArchiveData(string archiveUuid, string archiveFileId,
43
- ITapCloudSaveRequestCallback callback)
44
- {
45
- Bridge?.GetArchiveData(archiveUuid, archiveFileId, callback);
46
- }
35
+ internal static Task<ArchiveData> DeleteArchive(string archiveUuid) =>
36
+ Bridge?.DeleteArchive(archiveUuid);
47
37
 
48
- internal static void GetArchiveCover(string archiveUuid, string archiveFileId,
49
- ITapCloudSaveRequestCallback callback)
50
- {
51
- Bridge?.GetArchiveCover(archiveUuid, archiveFileId, callback);
52
- }
38
+ internal static Task<List<ArchiveData>> GetArchiveList() =>
39
+ Bridge?.GetArchiveList();
40
+
41
+ internal static Task<byte[]> GetArchiveData(string archiveUuid, string archiveFileId) =>
42
+ Bridge?.GetArchiveData(archiveUuid, archiveFileId);
43
+
44
+ internal static Task<byte[]> GetArchiveCover(string archiveUuid, string archiveFileId) =>
45
+ Bridge?.GetArchiveCover(archiveUuid, archiveFileId);
53
46
  }
54
47
  }