com.taptap.sdk.relationlite 4.10.1 → 4.10.3-beta.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 (44) hide show
  1. package/Mobile/Editor/BuidPostProcessor.cs +56 -56
  2. package/Mobile/Editor/BuidPostProcessor.cs.meta +11 -11
  3. package/Mobile/Editor/NativeDependencies.xml +14 -14
  4. package/Mobile/Editor/NativeDependencies.xml.meta +7 -7
  5. package/Mobile/Editor/TapRelationLiteMobileProcessBuild.cs.meta +11 -11
  6. package/Mobile/Editor/TapSDK.RelationLite.Mobile.Editor.asmdef +18 -18
  7. package/Mobile/Editor/TapSDK.RelationLite.Mobile.Editor.asmdef.meta +7 -7
  8. package/Mobile/Editor.meta +8 -8
  9. package/Mobile/Runtime/TapSDK.RelationLite.Mobile.Runtime.asmdef +22 -22
  10. package/Mobile/Runtime/TapSDK.RelationLite.Mobile.Runtime.asmdef.meta +7 -7
  11. package/Mobile/Runtime/TapTapRelationLiteImpl.cs +385 -385
  12. package/Mobile/Runtime/TapTapRelationLiteImpl.cs.meta +11 -11
  13. package/Mobile/Runtime.meta +8 -8
  14. package/Mobile.meta +8 -8
  15. package/Runtime/Internal/Init/RelationLiteInitTask.cs +19 -19
  16. package/Runtime/Internal/Init/RelationLiteInitTask.cs.meta +11 -11
  17. package/Runtime/Internal/Init.meta +8 -8
  18. package/Runtime/Internal/TapTapRelationLiteManager.cs +98 -98
  19. package/Runtime/Internal/TapTapRelationLiteManager.cs.meta +11 -11
  20. package/Runtime/Internal.meta +8 -8
  21. package/Runtime/Public/FollowStatus.cs +19 -19
  22. package/Runtime/Public/FollowStatus.cs.meta +11 -11
  23. package/Runtime/Public/ITapTapRelationLite.cs +30 -30
  24. package/Runtime/Public/ITapTapRelationLite.cs.meta +11 -11
  25. package/Runtime/Public/ITapTapRelationLiteCallback.cs +8 -8
  26. package/Runtime/Public/ITapTapRelationLiteCallback.cs.meta +11 -11
  27. package/Runtime/Public/ITapTapRelationLiteRequestCallback.cs +15 -15
  28. package/Runtime/Public/ITapTapRelationLiteRequestCallback.cs.meta +11 -11
  29. package/Runtime/Public/RelationLiteUserInfo.cs +19 -19
  30. package/Runtime/Public/RelationLiteUserInfo.cs.meta +11 -11
  31. package/Runtime/Public/RelationLiteUserItem.cs +17 -17
  32. package/Runtime/Public/RelationLiteUserItem.cs.meta +11 -11
  33. package/Runtime/Public/TapRelationLiteUserResult.cs +17 -17
  34. package/Runtime/Public/TapRelationLiteUserResult.cs.meta +7 -7
  35. package/Runtime/Public/TapTapRelationLite.cs +77 -77
  36. package/Runtime/Public/TapTapRelationLite.cs.meta +11 -11
  37. package/Runtime/Public.meta +8 -8
  38. package/Runtime/TapSDK.RelationLite.Runtime.asmdef +14 -14
  39. package/Runtime/TapSDK.RelationLite.Runtime.asmdef.meta +7 -7
  40. package/Runtime.meta +8 -8
  41. package/link.xml +3 -3
  42. package/link.xml.meta +7 -7
  43. package/package.json +11 -11
  44. package/package.json.meta +7 -7
@@ -1,386 +1,386 @@
1
- using System;
2
- using System.Collections;
3
- using System.Collections.Generic;
4
- using UnityEngine;
5
- using TapSDK.Core;
6
- using TapSDK.Core.Internal;
7
- using TapSDK.Core.Internal.Utils;
8
- using Newtonsoft.Json;
9
- using System.Runtime.InteropServices;
10
- using System.Threading.Tasks;
11
- using TapSDK.Core.Internal.Log;
12
- #if UNITY_IOS
13
- using UnityEngine.iOS;
14
- #endif
15
-
16
- namespace TapSDK.RelationLite
17
- {
18
- public class TapTapRelationLiteImpl : ITapTapRelationLite
19
- {
20
- private const string SERVICE_NAME = "BridgeRelationLiteService";
21
- private static List<ITapTapRelationLiteCallback> callbacks = new List<ITapTapRelationLiteCallback>();
22
- private static bool hasRegisterCallBack = false;
23
- private string _clientId;
24
- private TapTapRegionType _regionType;
25
-
26
- public TapTapRelationLiteImpl()
27
- {
28
- EngineBridge.GetInstance().Register(
29
- "com.taptap.sdk.relation.lite.unity.BridgeRelationLiteService",
30
- "com.taptap.sdk.relation.lite.unity.BridgeRelationLiteServiceImpl");
31
- }
32
-
33
- public void Init(string clientId, TapTapRegionType regionType)
34
- {
35
- _clientId = clientId;
36
- _regionType = regionType;
37
- TapLog.Log($"TapTapRelationLite Init with clientId: {clientId}, regionType: {regionType}");
38
- }
39
-
40
- public void InviteGame()
41
- {
42
- TapLog.Log("TapTapRelationLite InviteGame");
43
-
44
- EngineBridge.GetInstance().CallHandler(new Command.Builder()
45
- .Service(SERVICE_NAME)
46
- .Method("inviteGameByRelationLite")
47
- .Callback(false)
48
- .OnceTime(true)
49
- .CommandBuilder());
50
- }
51
-
52
- public void InviteTeam(string teamId)
53
- {
54
- TapLog.Log($"TapTapRelationLite InviteTeam with teamId: {teamId}");
55
-
56
- EngineBridge.GetInstance().CallHandler(new Command.Builder()
57
- .Service(SERVICE_NAME)
58
- .Method("inviteTeam")
59
- .Args("relationLiteTeamId", teamId)
60
- .Callback(false)
61
- .OnceTime(true)
62
- .CommandBuilder());
63
- }
64
-
65
- public Task<RelationLiteUserResult> GetFriendsList(string nextPageToken)
66
- {
67
- var taskSource = new TaskCompletionSource<RelationLiteUserResult>();
68
- TapLog.Log($"TapTapRelationLite GetFriendsList with nextPageToken: {nextPageToken}");
69
-
70
- EngineBridge.GetInstance().CallHandler(new Command.Builder()
71
- .Service(SERVICE_NAME)
72
- .Method("getFriendsList")
73
- .Args("friendListNextPageToken", nextPageToken)
74
- .Callback(true)
75
- .OnceTime(true)
76
- .CommandBuilder(), (result) =>
77
- {
78
- try
79
- {
80
- if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
81
- {
82
- taskSource.TrySetException(new TapException(-1, "Failed to get friends list with error code: " + result.code + " and content: " + result.content));
83
- return;
84
- }
85
-
86
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
87
- if (dic != null && dic.ContainsKey("next_page_token") && dic.ContainsKey("friends_list"))
88
- {
89
- string nextPage = SafeDictionary.GetValue<string>(dic, "next_page_token");
90
- string jsonStr = SafeDictionary.GetValue<string>(dic, "friends_list");
91
- List<RelationLiteUserItem> friendsList = JsonConvert.DeserializeObject<List<RelationLiteUserItem>>(jsonStr);
92
- taskSource.TrySetResult(new RelationLiteUserResult(friendsList, nextPage));
93
- }
94
- else
95
- {
96
- string errorMessage = SafeDictionary.GetValue<string>(dic, "error_message", "unknown error");
97
- taskSource.TrySetException(new TapException(-1, errorMessage));
98
- }
99
- }
100
- catch (Exception e)
101
- {
102
- taskSource.TrySetException(new TapException(-1, e.Message));
103
- TapLog.Error($"GetFriendsList parse result error: {e.Message}");
104
- }
105
- });
106
- return taskSource.Task;
107
- }
108
-
109
- public Task<RelationLiteUserResult> GetFollowingList(string nextPageToken)
110
- {
111
- var taskSource = new TaskCompletionSource<RelationLiteUserResult>();
112
- TapLog.Log($"TapTapRelationLite GetFollowingList with nextPageToken: {nextPageToken}");
113
-
114
- EngineBridge.GetInstance().CallHandler(new Command.Builder()
115
- .Service(SERVICE_NAME)
116
- .Method("getFollowingList")
117
- .Args("followingListNextPageToken", nextPageToken)
118
- .Callback(true)
119
- .OnceTime(true)
120
- .CommandBuilder(), (result) =>
121
- {
122
- try
123
- {
124
- if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
125
- {
126
- taskSource.TrySetException(new TapException(-1, "Failed to get friends list with error code: " + result.code + " and content: " + result.content));
127
- return;
128
- }
129
-
130
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
131
- if (dic != null && dic.ContainsKey("next_page_token") && dic.ContainsKey("following_list"))
132
- {
133
- string nextPage = SafeDictionary.GetValue<string>(dic, "next_page_token");
134
- string jsonStr = SafeDictionary.GetValue<string>(dic, "following_list");
135
- List<RelationLiteUserItem> followingList = JsonConvert.DeserializeObject<List<RelationLiteUserItem>>(jsonStr);
136
- taskSource.TrySetResult(new RelationLiteUserResult(followingList, nextPage));
137
- }
138
- else
139
- {
140
- string errorMessage = SafeDictionary.GetValue<string>(dic, "error_message", "unknown error");
141
- taskSource.TrySetException(new TapException(-1, errorMessage));
142
- }
143
- }
144
- catch (Exception e)
145
- {
146
- taskSource.TrySetException(new TapException(-1, e.Message));
147
- TapLog.Error($"GetFollowingList parse result error: {e.Message}");
148
- }
149
- });
150
- return taskSource.Task;
151
- }
152
-
153
- public Task<RelationLiteUserResult> GetFansList(string nextPageToken)
154
- {
155
- var taskSource = new TaskCompletionSource<RelationLiteUserResult>();
156
- TapLog.Log($"TapTapRelationLite GetFansList with nextPageToken: {nextPageToken}");
157
-
158
- EngineBridge.GetInstance().CallHandler(new Command.Builder()
159
- .Service(SERVICE_NAME)
160
- .Method("getFansList")
161
- .Args("fansListNextPageToken", nextPageToken)
162
- .Callback(true)
163
- .OnceTime(true)
164
- .CommandBuilder(), (result) =>
165
- {
166
- try
167
- {
168
- if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
169
- {
170
- taskSource.TrySetException(new TapException(-1, "Failed to get fans list with error code: " + result.code + " and content: " + result.content));
171
- return;
172
- }
173
-
174
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
175
- if (dic != null && dic.ContainsKey("next_page_token") && dic.ContainsKey("fans_list"))
176
- {
177
- string nextPage = SafeDictionary.GetValue<string>(dic, "next_page_token");
178
- string jsonStr = SafeDictionary.GetValue<string>(dic, "fans_list");
179
- List<RelationLiteUserItem> fansList = JsonConvert.DeserializeObject<List<RelationLiteUserItem>>(jsonStr);
180
- taskSource.TrySetResult(new RelationLiteUserResult(fansList, nextPage));
181
- }
182
- else
183
- {
184
- string errorMessage = SafeDictionary.GetValue<string>(dic, "error_message", "unknown error");
185
- taskSource.TrySetException(new TapException(-1, errorMessage));
186
- }
187
- }
188
- catch (Exception e)
189
- {
190
- taskSource.TrySetException(new TapException(-1, e.Message));
191
- TapLog.Error($"GetFansList parse result error: {e.Message}");
192
- }
193
- });
194
- return taskSource.Task;
195
- }
196
-
197
- public Task SyncRelationshipWithOpenId(int action, string nickname, string friendNickname, string friendOpenId)
198
- {
199
- var taskSource = new TaskCompletionSource<bool>();
200
- TapLog.Log($"TapTapRelationLite SyncRelationshipWithOpenId with action: {action}, nickname: {nickname}, friendNickname: {friendNickname}, friendOpenId: {friendOpenId}");
201
-
202
- EngineBridge.GetInstance().CallHandler(new Command.Builder()
203
- .Service(SERVICE_NAME)
204
- .Method("syncRelationshipWithOpenId")
205
- .Args("syncRelationAction", action)
206
- .Args("nickname", nickname)
207
- .Args("friendNickname", friendNickname)
208
- .Args("friendOpenId", friendOpenId)
209
- .Callback(true)
210
- .OnceTime(true)
211
- .CommandBuilder(), (result) =>
212
- {
213
-
214
- try
215
- {
216
- if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
217
- {
218
- taskSource.TrySetException(new TapException(-1, "Failed to sync relationship with open id with error code: " + result.code + " and content: " + result.content));
219
- return;
220
- }
221
-
222
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
223
- if (dic != null && dic.ContainsKey("success"))
224
- {
225
- int success = SafeDictionary.GetValue<int>(dic, "success", -1);
226
- if (success == 0)
227
- {
228
- taskSource.TrySetResult(true);
229
- }
230
- else
231
- {
232
- string errorMessage = SafeDictionary.GetValue<string>(dic, "error_message", "unknown error");
233
- taskSource.TrySetException(new TapException(-1, errorMessage));
234
- }
235
- }
236
- else
237
- {
238
- taskSource.TrySetException(new TapException(-1, "Failed to sync relationship with open id with error code: " + result.code + " and content: " + result.content));
239
-
240
- }
241
- }
242
- catch (Exception e)
243
- {
244
- taskSource.TrySetException(new TapException(-1, e.Message));
245
- TapLog.Error($"SyncRelationshipWithOpenId parse result error: {e.Message}");
246
- }
247
- });
248
- return taskSource.Task;
249
- }
250
-
251
- public Task SyncRelationshipWithUnionId(int action, string nickname, string friendNickname, string friendUnionId)
252
- {
253
- var taskSource = new TaskCompletionSource<bool>();
254
- TapLog.Log($"TapTapRelationLite SyncRelationshipWithUnionId with action: {action}, nickname: {nickname}, friendNickname: {friendNickname}, friendUnionId: {friendUnionId}");
255
-
256
- EngineBridge.GetInstance().CallHandler(new Command.Builder()
257
- .Service(SERVICE_NAME)
258
- .Method("syncRelationshipWithUnionId")
259
- .Args("syncRelationAction", action)
260
- .Args("nickname", nickname)
261
- .Args("friendNickname", friendNickname)
262
- .Args("friendUnionId", friendUnionId)
263
- .Callback(true)
264
- .OnceTime(true)
265
- .CommandBuilder(), (result) =>
266
- {
267
- try
268
- {
269
- if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
270
- {
271
- taskSource.TrySetException(new TapException(-1, "Failed to sync relationship with union id with error code: " + result.code + " and content: " + result.content));
272
- return;
273
- }
274
-
275
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
276
- if (dic != null && dic.ContainsKey("success"))
277
- {
278
- int success = SafeDictionary.GetValue<int>(dic, "success", -1);
279
- if (success == 0)
280
- {
281
- taskSource.TrySetResult(true);
282
- }
283
- else
284
- {
285
- string errorMessage = SafeDictionary.GetValue<string>(dic, "error_message", "unknown error");
286
- int errorCode = SafeDictionary.GetValue<int>(dic, "error_code", -1);
287
- taskSource.TrySetException(new TapException(errorCode, errorMessage));
288
- }
289
- }
290
- else
291
- {
292
- taskSource.TrySetException(new TapException(-1, "Failed to sync relationship with union id with error code: " + result.code + " and content: " + result.content));
293
- }
294
- }
295
- catch (Exception e)
296
- {
297
- taskSource.TrySetException(new TapException(-1, e.Message));
298
- TapLog.Error($"SyncRelationshipWithOpenId parse result error: {e.Message}");
299
- }
300
- });
301
- return taskSource.Task;
302
- }
303
-
304
- public void ShowTapUserProfile(string openId, string unionId)
305
- {
306
- TapLog.Log($"TapTapRelationLite ShowTapUserProfile with openId: {openId}, unionId: {unionId}");
307
-
308
- EngineBridge.GetInstance().CallHandler(new Command.Builder()
309
- .Service(SERVICE_NAME)
310
- .Method("showTapUserProfile")
311
- .Args("relationLiteOpenId", openId)
312
- .Args("unionId", unionId)
313
- .Callback(false)
314
- .OnceTime(true)
315
- .CommandBuilder());
316
- }
317
-
318
- public void RegisterRelationLiteCallback(ITapTapRelationLiteCallback callback)
319
- {
320
- if (callback == null) return;
321
- InitRegisterCallBack();
322
- if (!callbacks.Contains(callback))
323
- {
324
- callbacks.Add(callback);
325
- TapLog.Log("TapTapRelationLite RegisterRelationLiteCallback");
326
- }
327
- }
328
-
329
- public void UnregisterRelationLiteCallback(ITapTapRelationLiteCallback callback)
330
- {
331
- if (callback != null)
332
- {
333
- callbacks.Remove(callback);
334
- // 当引擎中清除所有回调时,移除原生 callback
335
- if (callbacks.Count == 0)
336
- {
337
- var command = new Command.Builder()
338
- .Service(SERVICE_NAME)
339
- .Method("unregisterRelationLiteCallback")
340
- .Callback(false)
341
- .OnceTime(false);
342
- EngineBridge.GetInstance().CallHandler(command.CommandBuilder());
343
- TapLog.Log("TapTapRelationLite UnregisterRelationLiteCallback");
344
- }
345
- }
346
- }
347
-
348
- private void InitRegisterCallBack()
349
- {
350
- if (hasRegisterCallBack)
351
- {
352
- return;
353
- }
354
- hasRegisterCallBack = true;
355
-
356
- var command = new Command.Builder();
357
- command.Service(SERVICE_NAME);
358
- command.Method("registerRelationLiteCallback")
359
- .Callback(true)
360
- .OnceTime(false);
361
- EngineBridge.GetInstance().CallHandler(command.CommandBuilder(), (result) =>
362
- {
363
- if (result.code != Result.RESULT_SUCCESS)
364
- {
365
- return;
366
- }
367
-
368
- if (string.IsNullOrEmpty(result.content))
369
- {
370
- return;
371
- }
372
- TapLog.Log("TapSdk4UnityDemo -->> Bridge Callback == " + JsonConvert.SerializeObject(result));
373
- var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
374
- var code = SafeDictionary.GetValue<int>(dic, "relation_lite_result_code");
375
-
376
- if (code != null)
377
- {
378
- callbacks.ForEach((x) => x.OnResult(code));
379
- }
380
-
381
- });
382
-
383
- TapLog.Log("TapTapRelationLite InitRegisterCallBack");
384
- }
385
- }
1
+ using System;
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+ using UnityEngine;
5
+ using TapSDK.Core;
6
+ using TapSDK.Core.Internal;
7
+ using TapSDK.Core.Internal.Utils;
8
+ using Newtonsoft.Json;
9
+ using System.Runtime.InteropServices;
10
+ using System.Threading.Tasks;
11
+ using TapSDK.Core.Internal.Log;
12
+ #if UNITY_IOS
13
+ using UnityEngine.iOS;
14
+ #endif
15
+
16
+ namespace TapSDK.RelationLite
17
+ {
18
+ public class TapTapRelationLiteImpl : ITapTapRelationLite
19
+ {
20
+ private const string SERVICE_NAME = "BridgeRelationLiteService";
21
+ private static List<ITapTapRelationLiteCallback> callbacks = new List<ITapTapRelationLiteCallback>();
22
+ private static bool hasRegisterCallBack = false;
23
+ private string _clientId;
24
+ private TapTapRegionType _regionType;
25
+
26
+ public TapTapRelationLiteImpl()
27
+ {
28
+ EngineBridge.GetInstance().Register(
29
+ "com.taptap.sdk.relation.lite.unity.BridgeRelationLiteService",
30
+ "com.taptap.sdk.relation.lite.unity.BridgeRelationLiteServiceImpl");
31
+ }
32
+
33
+ public void Init(string clientId, TapTapRegionType regionType)
34
+ {
35
+ _clientId = clientId;
36
+ _regionType = regionType;
37
+ TapLog.Log($"TapTapRelationLite Init with clientId: {clientId}, regionType: {regionType}");
38
+ }
39
+
40
+ public void InviteGame()
41
+ {
42
+ TapLog.Log("TapTapRelationLite InviteGame");
43
+
44
+ EngineBridge.GetInstance().CallHandler(new Command.Builder()
45
+ .Service(SERVICE_NAME)
46
+ .Method("inviteGameByRelationLite")
47
+ .Callback(false)
48
+ .OnceTime(true)
49
+ .CommandBuilder());
50
+ }
51
+
52
+ public void InviteTeam(string teamId)
53
+ {
54
+ TapLog.Log($"TapTapRelationLite InviteTeam with teamId: {teamId}");
55
+
56
+ EngineBridge.GetInstance().CallHandler(new Command.Builder()
57
+ .Service(SERVICE_NAME)
58
+ .Method("inviteTeam")
59
+ .Args("relationLiteTeamId", teamId)
60
+ .Callback(false)
61
+ .OnceTime(true)
62
+ .CommandBuilder());
63
+ }
64
+
65
+ public Task<RelationLiteUserResult> GetFriendsList(string nextPageToken)
66
+ {
67
+ var taskSource = new TaskCompletionSource<RelationLiteUserResult>();
68
+ TapLog.Log($"TapTapRelationLite GetFriendsList with nextPageToken: {nextPageToken}");
69
+
70
+ EngineBridge.GetInstance().CallHandler(new Command.Builder()
71
+ .Service(SERVICE_NAME)
72
+ .Method("getFriendsList")
73
+ .Args("friendListNextPageToken", nextPageToken)
74
+ .Callback(true)
75
+ .OnceTime(true)
76
+ .CommandBuilder(), (result) =>
77
+ {
78
+ try
79
+ {
80
+ if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
81
+ {
82
+ taskSource.TrySetException(new TapException(-1, "Failed to get friends list with error code: " + result.code + " and content: " + result.content));
83
+ return;
84
+ }
85
+
86
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
87
+ if (dic != null && dic.ContainsKey("next_page_token") && dic.ContainsKey("friends_list"))
88
+ {
89
+ string nextPage = SafeDictionary.GetValue<string>(dic, "next_page_token");
90
+ string jsonStr = SafeDictionary.GetValue<string>(dic, "friends_list");
91
+ List<RelationLiteUserItem> friendsList = JsonConvert.DeserializeObject<List<RelationLiteUserItem>>(jsonStr);
92
+ taskSource.TrySetResult(new RelationLiteUserResult(friendsList, nextPage));
93
+ }
94
+ else
95
+ {
96
+ string errorMessage = SafeDictionary.GetValue<string>(dic, "error_message", "unknown error");
97
+ taskSource.TrySetException(new TapException(-1, errorMessage));
98
+ }
99
+ }
100
+ catch (Exception e)
101
+ {
102
+ taskSource.TrySetException(new TapException(-1, e.Message));
103
+ TapLog.Error($"GetFriendsList parse result error: {e.Message}");
104
+ }
105
+ });
106
+ return taskSource.Task;
107
+ }
108
+
109
+ public Task<RelationLiteUserResult> GetFollowingList(string nextPageToken)
110
+ {
111
+ var taskSource = new TaskCompletionSource<RelationLiteUserResult>();
112
+ TapLog.Log($"TapTapRelationLite GetFollowingList with nextPageToken: {nextPageToken}");
113
+
114
+ EngineBridge.GetInstance().CallHandler(new Command.Builder()
115
+ .Service(SERVICE_NAME)
116
+ .Method("getFollowingList")
117
+ .Args("followingListNextPageToken", nextPageToken)
118
+ .Callback(true)
119
+ .OnceTime(true)
120
+ .CommandBuilder(), (result) =>
121
+ {
122
+ try
123
+ {
124
+ if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
125
+ {
126
+ taskSource.TrySetException(new TapException(-1, "Failed to get friends list with error code: " + result.code + " and content: " + result.content));
127
+ return;
128
+ }
129
+
130
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
131
+ if (dic != null && dic.ContainsKey("next_page_token") && dic.ContainsKey("following_list"))
132
+ {
133
+ string nextPage = SafeDictionary.GetValue<string>(dic, "next_page_token");
134
+ string jsonStr = SafeDictionary.GetValue<string>(dic, "following_list");
135
+ List<RelationLiteUserItem> followingList = JsonConvert.DeserializeObject<List<RelationLiteUserItem>>(jsonStr);
136
+ taskSource.TrySetResult(new RelationLiteUserResult(followingList, nextPage));
137
+ }
138
+ else
139
+ {
140
+ string errorMessage = SafeDictionary.GetValue<string>(dic, "error_message", "unknown error");
141
+ taskSource.TrySetException(new TapException(-1, errorMessage));
142
+ }
143
+ }
144
+ catch (Exception e)
145
+ {
146
+ taskSource.TrySetException(new TapException(-1, e.Message));
147
+ TapLog.Error($"GetFollowingList parse result error: {e.Message}");
148
+ }
149
+ });
150
+ return taskSource.Task;
151
+ }
152
+
153
+ public Task<RelationLiteUserResult> GetFansList(string nextPageToken)
154
+ {
155
+ var taskSource = new TaskCompletionSource<RelationLiteUserResult>();
156
+ TapLog.Log($"TapTapRelationLite GetFansList with nextPageToken: {nextPageToken}");
157
+
158
+ EngineBridge.GetInstance().CallHandler(new Command.Builder()
159
+ .Service(SERVICE_NAME)
160
+ .Method("getFansList")
161
+ .Args("fansListNextPageToken", nextPageToken)
162
+ .Callback(true)
163
+ .OnceTime(true)
164
+ .CommandBuilder(), (result) =>
165
+ {
166
+ try
167
+ {
168
+ if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
169
+ {
170
+ taskSource.TrySetException(new TapException(-1, "Failed to get fans list with error code: " + result.code + " and content: " + result.content));
171
+ return;
172
+ }
173
+
174
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
175
+ if (dic != null && dic.ContainsKey("next_page_token") && dic.ContainsKey("fans_list"))
176
+ {
177
+ string nextPage = SafeDictionary.GetValue<string>(dic, "next_page_token");
178
+ string jsonStr = SafeDictionary.GetValue<string>(dic, "fans_list");
179
+ List<RelationLiteUserItem> fansList = JsonConvert.DeserializeObject<List<RelationLiteUserItem>>(jsonStr);
180
+ taskSource.TrySetResult(new RelationLiteUserResult(fansList, nextPage));
181
+ }
182
+ else
183
+ {
184
+ string errorMessage = SafeDictionary.GetValue<string>(dic, "error_message", "unknown error");
185
+ taskSource.TrySetException(new TapException(-1, errorMessage));
186
+ }
187
+ }
188
+ catch (Exception e)
189
+ {
190
+ taskSource.TrySetException(new TapException(-1, e.Message));
191
+ TapLog.Error($"GetFansList parse result error: {e.Message}");
192
+ }
193
+ });
194
+ return taskSource.Task;
195
+ }
196
+
197
+ public Task SyncRelationshipWithOpenId(int action, string nickname, string friendNickname, string friendOpenId)
198
+ {
199
+ var taskSource = new TaskCompletionSource<bool>();
200
+ TapLog.Log($"TapTapRelationLite SyncRelationshipWithOpenId with action: {action}, nickname: {nickname}, friendNickname: {friendNickname}, friendOpenId: {friendOpenId}");
201
+
202
+ EngineBridge.GetInstance().CallHandler(new Command.Builder()
203
+ .Service(SERVICE_NAME)
204
+ .Method("syncRelationshipWithOpenId")
205
+ .Args("syncRelationAction", action)
206
+ .Args("nickname", nickname)
207
+ .Args("friendNickname", friendNickname)
208
+ .Args("friendOpenId", friendOpenId)
209
+ .Callback(true)
210
+ .OnceTime(true)
211
+ .CommandBuilder(), (result) =>
212
+ {
213
+
214
+ try
215
+ {
216
+ if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
217
+ {
218
+ taskSource.TrySetException(new TapException(-1, "Failed to sync relationship with open id with error code: " + result.code + " and content: " + result.content));
219
+ return;
220
+ }
221
+
222
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
223
+ if (dic != null && dic.ContainsKey("success"))
224
+ {
225
+ int success = SafeDictionary.GetValue<int>(dic, "success", -1);
226
+ if (success == 0)
227
+ {
228
+ taskSource.TrySetResult(true);
229
+ }
230
+ else
231
+ {
232
+ string errorMessage = SafeDictionary.GetValue<string>(dic, "error_message", "unknown error");
233
+ taskSource.TrySetException(new TapException(-1, errorMessage));
234
+ }
235
+ }
236
+ else
237
+ {
238
+ taskSource.TrySetException(new TapException(-1, "Failed to sync relationship with open id with error code: " + result.code + " and content: " + result.content));
239
+
240
+ }
241
+ }
242
+ catch (Exception e)
243
+ {
244
+ taskSource.TrySetException(new TapException(-1, e.Message));
245
+ TapLog.Error($"SyncRelationshipWithOpenId parse result error: {e.Message}");
246
+ }
247
+ });
248
+ return taskSource.Task;
249
+ }
250
+
251
+ public Task SyncRelationshipWithUnionId(int action, string nickname, string friendNickname, string friendUnionId)
252
+ {
253
+ var taskSource = new TaskCompletionSource<bool>();
254
+ TapLog.Log($"TapTapRelationLite SyncRelationshipWithUnionId with action: {action}, nickname: {nickname}, friendNickname: {friendNickname}, friendUnionId: {friendUnionId}");
255
+
256
+ EngineBridge.GetInstance().CallHandler(new Command.Builder()
257
+ .Service(SERVICE_NAME)
258
+ .Method("syncRelationshipWithUnionId")
259
+ .Args("syncRelationAction", action)
260
+ .Args("nickname", nickname)
261
+ .Args("friendNickname", friendNickname)
262
+ .Args("friendUnionId", friendUnionId)
263
+ .Callback(true)
264
+ .OnceTime(true)
265
+ .CommandBuilder(), (result) =>
266
+ {
267
+ try
268
+ {
269
+ if (result.code != Result.RESULT_SUCCESS || string.IsNullOrEmpty(result.content))
270
+ {
271
+ taskSource.TrySetException(new TapException(-1, "Failed to sync relationship with union id with error code: " + result.code + " and content: " + result.content));
272
+ return;
273
+ }
274
+
275
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
276
+ if (dic != null && dic.ContainsKey("success"))
277
+ {
278
+ int success = SafeDictionary.GetValue<int>(dic, "success", -1);
279
+ if (success == 0)
280
+ {
281
+ taskSource.TrySetResult(true);
282
+ }
283
+ else
284
+ {
285
+ string errorMessage = SafeDictionary.GetValue<string>(dic, "error_message", "unknown error");
286
+ int errorCode = SafeDictionary.GetValue<int>(dic, "error_code", -1);
287
+ taskSource.TrySetException(new TapException(errorCode, errorMessage));
288
+ }
289
+ }
290
+ else
291
+ {
292
+ taskSource.TrySetException(new TapException(-1, "Failed to sync relationship with union id with error code: " + result.code + " and content: " + result.content));
293
+ }
294
+ }
295
+ catch (Exception e)
296
+ {
297
+ taskSource.TrySetException(new TapException(-1, e.Message));
298
+ TapLog.Error($"SyncRelationshipWithOpenId parse result error: {e.Message}");
299
+ }
300
+ });
301
+ return taskSource.Task;
302
+ }
303
+
304
+ public void ShowTapUserProfile(string openId, string unionId)
305
+ {
306
+ TapLog.Log($"TapTapRelationLite ShowTapUserProfile with openId: {openId}, unionId: {unionId}");
307
+
308
+ EngineBridge.GetInstance().CallHandler(new Command.Builder()
309
+ .Service(SERVICE_NAME)
310
+ .Method("showTapUserProfile")
311
+ .Args("relationLiteOpenId", openId)
312
+ .Args("unionId", unionId)
313
+ .Callback(false)
314
+ .OnceTime(true)
315
+ .CommandBuilder());
316
+ }
317
+
318
+ public void RegisterRelationLiteCallback(ITapTapRelationLiteCallback callback)
319
+ {
320
+ if (callback == null) return;
321
+ InitRegisterCallBack();
322
+ if (!callbacks.Contains(callback))
323
+ {
324
+ callbacks.Add(callback);
325
+ TapLog.Log("TapTapRelationLite RegisterRelationLiteCallback");
326
+ }
327
+ }
328
+
329
+ public void UnregisterRelationLiteCallback(ITapTapRelationLiteCallback callback)
330
+ {
331
+ if (callback != null)
332
+ {
333
+ callbacks.Remove(callback);
334
+ // 当引擎中清除所有回调时,移除原生 callback
335
+ if (callbacks.Count == 0)
336
+ {
337
+ var command = new Command.Builder()
338
+ .Service(SERVICE_NAME)
339
+ .Method("unregisterRelationLiteCallback")
340
+ .Callback(false)
341
+ .OnceTime(false);
342
+ EngineBridge.GetInstance().CallHandler(command.CommandBuilder());
343
+ TapLog.Log("TapTapRelationLite UnregisterRelationLiteCallback");
344
+ }
345
+ }
346
+ }
347
+
348
+ private void InitRegisterCallBack()
349
+ {
350
+ if (hasRegisterCallBack)
351
+ {
352
+ return;
353
+ }
354
+ hasRegisterCallBack = true;
355
+
356
+ var command = new Command.Builder();
357
+ command.Service(SERVICE_NAME);
358
+ command.Method("registerRelationLiteCallback")
359
+ .Callback(true)
360
+ .OnceTime(false);
361
+ EngineBridge.GetInstance().CallHandler(command.CommandBuilder(), (result) =>
362
+ {
363
+ if (result.code != Result.RESULT_SUCCESS)
364
+ {
365
+ return;
366
+ }
367
+
368
+ if (string.IsNullOrEmpty(result.content))
369
+ {
370
+ return;
371
+ }
372
+ TapLog.Log("TapSdk4UnityDemo -->> Bridge Callback == " + JsonConvert.SerializeObject(result));
373
+ var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
374
+ var code = SafeDictionary.GetValue<int>(dic, "relation_lite_result_code");
375
+
376
+ if (code != null)
377
+ {
378
+ callbacks.ForEach((x) => x.OnResult(code));
379
+ }
380
+
381
+ });
382
+
383
+ TapLog.Log("TapTapRelationLite InitRegisterCallBack");
384
+ }
385
+ }
386
386
  }