com.taptap.sdk.core 4.3.12 → 4.4.0

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 (50) hide show
  1. package/Mobile/Editor/NativeDependencies.xml +2 -2
  2. package/Resources/TapMessage.prefab +352 -0
  3. package/Resources/TapMessage.prefab.meta +10 -0
  4. package/Resources/TapSDKUIRoot.prefab +1 -1
  5. package/Resources/tap_toast_background.png +0 -0
  6. package/Resources/tap_toast_background.png.meta +128 -0
  7. package/Resources/tap_toast_background1.png +0 -0
  8. package/Resources/tap_toast_background1.png.meta +128 -0
  9. package/Runtime/Internal/Log/TapLog.cs +1 -1
  10. package/Runtime/Internal/Platform/PlatformTypeUtils.cs +5 -5
  11. package/Runtime/Internal/Utils/TapMessage.cs +69 -0
  12. package/Runtime/Internal/Utils/TapMessage.cs.meta +13 -0
  13. package/Runtime/Public/TapTapSDK.cs +1 -1
  14. package/Standalone/Runtime/Internal/Bean/TapGatekeeper.cs +42 -0
  15. package/Standalone/Runtime/Internal/{Http/TimeUtil.cs.meta → Bean/TapGatekeeper.cs.meta} +1 -1
  16. package/Standalone/Runtime/Internal/Bean.meta +8 -0
  17. package/Standalone/Runtime/Internal/Constants.cs +2 -2
  18. package/Standalone/Runtime/Internal/EventSender.cs +30 -19
  19. package/Standalone/Runtime/Internal/Http/TapHttp.cs +377 -0
  20. package/Standalone/Runtime/Internal/Http/{HttpClient.cs.meta → TapHttp.cs.meta} +1 -1
  21. package/Standalone/Runtime/Internal/Http/TapHttpBuilder.cs +92 -0
  22. package/Standalone/Runtime/Internal/Http/{NetUtils.cs.meta → TapHttpBuilder.cs.meta} +1 -1
  23. package/Standalone/Runtime/Internal/Http/TapHttpErrorConstants.cs +114 -0
  24. package/Standalone/Runtime/Internal/Http/TapHttpErrorConstants.cs.meta +11 -0
  25. package/Standalone/Runtime/Internal/Http/TapHttpException.cs +71 -0
  26. package/Standalone/Runtime/Internal/Http/TapHttpException.cs.meta +11 -0
  27. package/Standalone/Runtime/Internal/Http/TapHttpParser.cs +132 -0
  28. package/Standalone/Runtime/Internal/Http/TapHttpParser.cs.meta +11 -0
  29. package/Standalone/Runtime/Internal/Http/TapHttpResponse.cs +37 -0
  30. package/Standalone/Runtime/Internal/Http/TapHttpResponse.cs.meta +11 -0
  31. package/Standalone/Runtime/Internal/Http/TapHttpResult.cs +90 -0
  32. package/Standalone/Runtime/Internal/Http/TapHttpResult.cs.meta +11 -0
  33. package/Standalone/Runtime/Internal/Http/TapHttpRetryStrategy.cs +237 -0
  34. package/Standalone/Runtime/Internal/Http/TapHttpRetryStrategy.cs.meta +11 -0
  35. package/Standalone/Runtime/Internal/Http/TapHttpSign.cs +137 -0
  36. package/Standalone/Runtime/Internal/Http/TapHttpSign.cs.meta +11 -0
  37. package/Standalone/Runtime/Internal/Http/TapHttpUtils.cs +166 -0
  38. package/Standalone/Runtime/Internal/Http/TapHttpUtils.cs.meta +11 -0
  39. package/Standalone/Runtime/Internal/Openlog/TapOpenlogHttpClient.cs +6 -17
  40. package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBase.cs +1 -1
  41. package/Standalone/Runtime/Internal/service/ITapLoginService.cs +9 -0
  42. package/Standalone/Runtime/Internal/service/ITapLoginService.cs.meta +11 -0
  43. package/Standalone/Runtime/Internal/service.meta +8 -0
  44. package/Standalone/Runtime/Public/TapCoreStandalone.cs +67 -81
  45. package/link.xml +4 -0
  46. package/link.xml.meta +7 -0
  47. package/package.json +1 -1
  48. package/Standalone/Runtime/Internal/Http/HttpClient.cs +0 -211
  49. package/Standalone/Runtime/Internal/Http/NetUtils.cs +0 -48
  50. package/Standalone/Runtime/Internal/Http/TimeUtil.cs +0 -30
@@ -6,6 +6,10 @@ using UnityEditor;
6
6
  using System.IO;
7
7
  using TapSDK.Core.Internal.Utils;
8
8
  using TapSDK.Core.Standalone.Internal.Openlog;
9
+ using TapSDK.Core.Internal.Log;
10
+ using TapSDK.Core.Standalone.Internal.Http;
11
+ using Newtonsoft.Json;
12
+ using TapSDK.Core.Standalone.Internal.Bean;
9
13
 
10
14
  namespace TapSDK.Core.Standalone
11
15
  {
@@ -21,7 +25,9 @@ namespace TapSDK.Core.Standalone
21
25
  public static bool isRnd = false;
22
26
  internal static bool enableAutoEvent = true;
23
27
 
24
- internal static Dictionary<string, object> gatekeeperData = new Dictionary<string, object>();
28
+ internal static TapGatekeeper gatekeeperData = new TapGatekeeper();
29
+
30
+ private readonly TapHttp tapHttp = TapHttp.NewBuilder("TapSDKCore", TapTapSDK.Version).Build();
25
31
 
26
32
  /// <summary>
27
33
  /// Initializes a new instance of the <see cref="TapCoreStandalone"/> class.
@@ -38,7 +44,7 @@ namespace TapSDK.Core.Standalone
38
44
 
39
45
  private static void SetRND(bool isRnd)
40
46
  {
41
- Debug.Log("SetRND called" + isRnd);
47
+ TapLog.Log("SetRND called = " + isRnd);
42
48
  TapCoreStandalone.isRnd = isRnd;
43
49
  }
44
50
 
@@ -58,30 +64,29 @@ namespace TapSDK.Core.Standalone
58
64
  /// <param name="otherOptions">Additional TapCore SDK options.</param>
59
65
  public void Init(TapTapSdkOptions coreOption, TapTapSdkBaseOptions[] otherOptions)
60
66
  {
61
- Debug.Log("SDK inited with other options + " + coreOption.ToString() + coreOption.ToString());
67
+ TapLog.Log("SDK inited with other options + " + coreOption.ToString() + coreOption.ToString());
62
68
  coreOptions = coreOption;
63
69
 
64
70
  var path = Path.Combine(Application.persistentDataPath, Constants.ClientSettingsFileName);
65
71
  if (File.Exists(path))
66
72
  {
67
73
  var clientSettings = File.ReadAllText(path);
68
- Debug.Log("本地 clientSettings: " + clientSettings);
69
- SetAutoEvent(Json.Deserialize(clientSettings) as Dictionary<string, object>);
70
-
74
+ TapLog.Log("本地 clientSettings: " + clientSettings);
71
75
  try
72
76
  {
73
- gatekeeperData = Json.Deserialize(clientSettings) as Dictionary<string, object>;
77
+ TapGatekeeper tapGatekeeper = JsonConvert.DeserializeObject<TapGatekeeper>(clientSettings);
78
+ SetAutoEvent(tapGatekeeper);
79
+ gatekeeperData = tapGatekeeper;
74
80
  }
75
81
  catch (System.Exception e)
76
82
  {
77
- Debug.LogError("TriggerEvent error: " + e.Message);
83
+ TapLog.Warning("TriggerEvent error: " + e.Message);
78
84
  }
79
85
  }
80
86
 
81
87
  Tracker.Init();
82
88
 
83
89
  TapOpenlogStandalone.Init();
84
-
85
90
  requestClientSetting();
86
91
  }
87
92
 
@@ -92,102 +97,83 @@ namespace TapSDK.Core.Standalone
92
97
  Debug.Log("coreOptions is null");
93
98
  return;
94
99
  }
95
- Debug.Log("UpdateLanguage called with language: " + language);
100
+ TapLog.Log("UpdateLanguage called with language: " + language);
96
101
  coreOptions.preferredLanguage = language;
97
102
  }
98
103
 
99
- public static string getGatekeeperConfigUrl(string key)
100
- {
101
- if (gatekeeperData != null)
102
- {
103
- var urlsData = gatekeeperData["urls"] as Dictionary<string, object>;
104
- if (urlsData != null && urlsData.ContainsKey(key))
105
- {
106
- var keyData = urlsData[key] as Dictionary<string, object>;
107
- if (keyData != null)
108
- {
109
- return (string)keyData["browser"];
110
- }
111
- }
112
- }
113
- return null;
114
- }
104
+ public static string getGatekeeperConfigUrl(string key)
105
+ {
106
+ if (gatekeeperData != null)
107
+ {
108
+ var urlsData = gatekeeperData.Urls;
109
+ if (urlsData != null && urlsData.ContainsKey(key))
110
+ {
111
+ var keyData = urlsData[key];
112
+ if (keyData != null)
113
+ {
114
+ return keyData.Browser;
115
+ }
116
+ }
117
+ }
118
+ return null;
119
+ }
115
120
 
116
- private async void requestClientSetting()
121
+ private void requestClientSetting()
117
122
  {
118
123
  // 使用 httpclient 请求 /sdk-core/v1/gatekeeper 获取配置
119
- HttpClientConfig config = new HttpClientConfig(Constants.TAPSDK_HOST, null, true);
120
- var httpClient = new HttpClient(config);
121
124
  #if UNITY_EDITOR
122
125
  var bundleIdentifier = PlayerSettings.applicationIdentifier;
123
126
  #else
124
127
  var bundleIdentifier = Application.identifier;
125
128
  #endif
126
- var path = $"sdk-core/v1/gatekeeper?client_id={coreOptions.clientId}";
129
+ var path = "sdk-core/v1/gatekeeper";
127
130
  var body = new Dictionary<string, object> {
128
131
  { "platform", "pc" },
129
132
  { "bundle_id", bundleIdentifier }
130
133
  };
131
- var response = await httpClient.Post(path, body, headers: NetUtils.commonHeaders);
132
- if (response != null)
133
- {
134
- var responseJson = Json.Deserialize(response) as Dictionary<string, object>;
135
- if (responseJson != null)
136
- {
137
- /**
138
- * {
139
- * "data": {
140
- * "check": {},
141
- * "switch": {
142
- * "auto_event": true,
143
- * "heartbeat": true
144
- * },
145
- * "urls": {
146
- * "achievement_my_list_url": {
147
- * "webview": "https://tapsdk.xdrnd.cn/achievement/me?client_id=rfciqabirt4vqav7io",
148
- * "browser": "https://www.xdrnd.cn/app/70253/achievement/6"
149
- * }
150
- * },
151
- * "webview": {
152
- * "js_bridge": {
153
- * "host_allowlist": [
154
- * "tapsdk.xdrnd.cn"
155
- * ]
156
- * }
157
- * }
158
- * },
159
- * "now": 1719972670,
160
- * "success": true
161
- * }
162
- */
163
- var isSuccess = (bool)responseJson["success"];
164
- if (isSuccess)
165
- {
166
- var data = responseJson["data"] as Dictionary<string, object>;
167
- SetAutoEvent(data);
168
- gatekeeperData = data;
169
- // 把 data 存储在本地
170
- saveClientSettings(data);
171
- // 发通知
172
- EventManager.TriggerEvent(Constants.ClientSettingsEventKey, data);
173
- }
174
- }
175
- }
134
+
135
+ tapHttp.PostJson<TapGatekeeper>(
136
+ url: path,
137
+ json: body,
138
+ onSuccess: (data) =>
139
+ {
140
+ SetAutoEvent(data);
141
+ gatekeeperData = data;
142
+ // 把 data 存储在本地
143
+ saveClientSettings(data);
144
+ // 发通知
145
+ EventManager.TriggerEvent(Constants.ClientSettingsEventKey, data);
146
+ },
147
+ onFailure: (error) =>
148
+ {
149
+ if (error is TapHttpServerException se)
150
+ {
151
+ if (TapHttpErrorConstants.ERROR_INVALID_CLIENT.Equals(se.ErrorData.Error))
152
+ {
153
+ TapLog.Error("Init Failed", se.ErrorData.ErrorDescription);
154
+ TapMessage.ShowMessage(se.ErrorData.Msg, TapMessage.Position.bottom, TapMessage.Time.twoSecond);
155
+ }
156
+ }
157
+ }
158
+ );
176
159
  }
177
160
 
178
- private void saveClientSettings(Dictionary<string, object> settings)
161
+ private void saveClientSettings(TapGatekeeper settings)
179
162
  {
180
- string json = Json.Serialize(settings);
163
+ string json = JsonConvert.SerializeObject(settings);
181
164
  Debug.Log("saveClientSettings: " + json);
182
165
  File.WriteAllText(Path.Combine(Application.persistentDataPath, Constants.ClientSettingsFileName), json);
183
166
  }
184
167
 
185
- private void SetAutoEvent(Dictionary<string, object> data)
168
+ private void SetAutoEvent(TapGatekeeper gatekeeper)
186
169
  {
187
- if (data != null)
170
+ if (gatekeeper != null)
188
171
  {
189
- var switchData = data["switch"] as Dictionary<string, object>;
190
- enableAutoEvent = (bool)switchData["auto_event"];
172
+ var switchData = gatekeeper.Switch;
173
+ if (switchData != null)
174
+ {
175
+ enableAutoEvent = switchData.AutoEvent;
176
+ }
191
177
  }
192
178
  Debug.Log("SetAutoEvent enableAutoEvent is: " + enableAutoEvent);
193
179
  }
package/link.xml ADDED
@@ -0,0 +1,4 @@
1
+ <linker>
2
+ <assembly fullname="TapSDK.Core.Runtime" preserve="all" />
3
+ <assembly fullname="TapSDK.Core.Mobile.Runtime" preserve="all" />
4
+ </linker>
package/link.xml.meta ADDED
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 10ec9c4261b764ec0a94ec236fdabef6
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "com.taptap.sdk.core",
3
3
  "displayName": "TapTapSDK Core",
4
4
  "description": "TapTapSDK Core",
5
- "version": "4.3.12",
5
+ "version": "4.4.0",
6
6
  "unity": "2019.4",
7
7
  "license": "MIT",
8
8
  "dependencies": {
@@ -1,211 +0,0 @@
1
- using System;
2
- using System.Threading.Tasks;
3
- using System.Collections.Generic;
4
- using System.Net;
5
- using System.Net.Http;
6
- using System.Net.Http.Headers;
7
- using System.Linq;
8
- using UnityEngine;
9
- using System.Security.Cryptography;
10
- using System.Text;
11
-
12
- namespace TapSDK.Core.Standalone.Internal {
13
- // 网络请求类,使用示例
14
- /*
15
- HttpClientConfig config = new HttpClientConfig("https://api.example.com");
16
- config.DefaultHeaders.Add("Authorization", "Bearer your_token");
17
-
18
- HttpClient client = new HttpClient(config);
19
-
20
- // GET request
21
- Dictionary<string, string> queryParams = new Dictionary<string, string>
22
- {
23
- { "query1", "value1" },
24
- { "query2", "value2" }
25
- };
26
- string getResponse = await client.GetAsync("/path/to/resource", queryParams);
27
- UnityEngine.Debug.Log("GET Response: " + getResponse);
28
-
29
- // POST request
30
- string postBody = "{\"key\":\"value\"}";
31
- Dictionary<string, string> postHeaders = new Dictionary<string, string>
32
- {
33
- { "Content-Type", "application/json" }
34
- };
35
- string postResponse = await client.PostAsync("/path/to/resource", postBody, null, postHeaders);
36
- UnityEngine.Debug.Log("POST Response: " + postResponse);
37
- */
38
- public class HttpClientConfig {
39
- public string Host;
40
- public Dictionary<string, string> DefaultHeaders;
41
- public bool needSign = false;
42
-
43
- public HttpClientConfig(string host, Dictionary<string, string> defaultHeaders = null, bool needSign = false) {
44
- Host = host;
45
- if (defaultHeaders == null) {
46
- DefaultHeaders = new Dictionary<string, string>();
47
- } else {
48
- DefaultHeaders = defaultHeaders;
49
- }
50
- this.needSign = needSign;
51
- }
52
- }
53
-
54
- public class HttpClient {
55
- private readonly HttpClientConfig Config;
56
- private static readonly System.Net.Http.HttpClientHandler handler = new System.Net.Http.HttpClientHandler
57
- {
58
- Proxy = new WebProxy(GetProxyAddress(), true), // Charles 代理地址
59
- UseProxy = ShouldUseProxy()
60
- };
61
- private static readonly System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(handler);
62
-
63
- private static bool ShouldUseProxy()
64
- {
65
- string useProxyEnv = Environment.GetEnvironmentVariable("TAPSDK_USE_PROXY");
66
- return !string.IsNullOrEmpty(useProxyEnv) && useProxyEnv.Equals("true", StringComparison.OrdinalIgnoreCase);
67
- }
68
-
69
- private static string GetProxyAddress()
70
- {
71
- // 获取代理地址,默认值为 "http://localhost:8888"
72
- string proxyAddress = Environment.GetEnvironmentVariable("TAPSDK_PROXY_ADDRESS");
73
- return !string.IsNullOrEmpty(proxyAddress) ? proxyAddress : "http://localhost:8888";
74
- }
75
-
76
- public HttpClient(HttpClientConfig config)
77
- {
78
- this.Config = config;
79
- foreach (var header in this.Config.DefaultHeaders)
80
- {
81
- client.DefaultRequestHeaders.Add(header.Key, header.Value);
82
- }
83
- }
84
-
85
- public async Task<string> Get(string path, Dictionary<string, string> queryParameters = null, Dictionary<string, string> headers = null)
86
- {
87
- string url = BuildUrl(path, queryParameters);
88
- var request = new HttpRequestMessage(HttpMethod.Get, url);
89
-
90
- AddHeaders(request, headers);
91
-
92
- return await SendRequest(request);
93
- }
94
-
95
- public async Task<string> Post(string path, Dictionary<string, object> body, Dictionary<string, string> queryParameters = null, Dictionary<string, string> headers = null)
96
- {
97
- string url = BuildUrl(path, queryParameters);
98
- var request = new HttpRequestMessage(HttpMethod.Post, url);
99
-
100
- AddHeaders(request, headers);
101
-
102
- if (body != null)
103
- {
104
- string jsonBody = Json.Serialize(body);
105
- StringContent requestContent = new StringContent(jsonBody);
106
- requestContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
107
- request.Content = requestContent;
108
- }
109
-
110
- return await SendRequest(request);
111
- }
112
-
113
- private void AddHeaders(HttpRequestMessage request, Dictionary<string, string> headers)
114
- {
115
- // Add request-specific headers
116
- if (headers != null)
117
- {
118
- foreach (var header in headers)
119
- {
120
- request.Headers.Add(header.Key, header.Value);
121
- }
122
- }
123
- }
124
-
125
- public static async Task<string> Sign(HttpRequestMessage req, string secret)
126
- {
127
- string methodPart = req.Method.Method;
128
- string urlPathAndQueryPart = req.RequestUri.PathAndQuery;
129
-
130
- string headersPart = GetHeadersPart(req.Headers);
131
-
132
- string bodyPart = string.Empty;
133
- if (req.Content != null)
134
- {
135
- bodyPart = await req.Content.ReadAsStringAsync();
136
- }
137
-
138
- string signParts = methodPart + "\n" + urlPathAndQueryPart + "\n" + headersPart + "\n" + bodyPart + "\n";
139
-
140
- using (var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(secret)))
141
- {
142
- byte[] hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(signParts));
143
- return Convert.ToBase64String(hash);
144
- }
145
- }
146
-
147
- private static string GetHeadersPart(HttpRequestHeaders headers)
148
- {
149
- var headerKeys = headers
150
- .Where(h => h.Key.StartsWith("x-tap-", StringComparison.OrdinalIgnoreCase))
151
- .OrderBy(h => h.Key.ToLowerInvariant())
152
- .Select(h => $"{h.Key.ToLowerInvariant()}:{string.Join(",", h.Value)}")
153
- .ToList();
154
-
155
- return string.Join("\n", headerKeys);
156
- }
157
- private async Task<string> SendRequest(HttpRequestMessage request)
158
- {
159
- if (this.Config.needSign)
160
- {
161
- string sign = await Sign(request, TapCoreStandalone.coreOptions.clientToken);
162
- request.Headers.Add("X-Tap-Sign", sign);
163
- }
164
-
165
- HttpResponseMessage response;
166
-
167
- try
168
- {
169
- response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
170
- request.Dispose();
171
- }
172
- catch (HttpRequestException e)
173
- {
174
- Debug.Log($"Request error: {e}");
175
- return null;
176
- }
177
-
178
- string responseBody = await response.Content.ReadAsStringAsync();
179
- var responseJson = Json.Deserialize(responseBody) as Dictionary<string, object>;
180
- if (responseJson != null)
181
- {
182
- int now = (int)Convert.ToInt64(responseJson["now"]);
183
- if (now > 0)
184
- {
185
- TimeUtil.FixTime(now);
186
- }
187
- }
188
-
189
- Debug.Log($"Response Code: {response.StatusCode}, Body: {responseBody}");
190
-
191
- if (!response.IsSuccessStatusCode)
192
- {
193
- Debug.Log($"Error: {response}");
194
- return null;
195
- }
196
-
197
- response.Dispose();
198
- return responseBody;
199
- }
200
-
201
- private string BuildUrl(string path, Dictionary<string, string> queryParameters) {
202
- string url = $"{this.Config.Host}/{path}";
203
- if (queryParameters != null) {
204
- IEnumerable<string> queryPairs = queryParameters.Select(kv => $"{kv.Key}={Uri.EscapeDataString(kv.Value.ToString())}");
205
- string queries = string.Join("&", queryPairs);
206
- url = $"{url}?{queries}";
207
- }
208
- return url;
209
- }
210
- }
211
- }
@@ -1,48 +0,0 @@
1
- using System;
2
- using System.Collections.Generic;
3
- using System.Linq;
4
- using System.Security.Cryptography;
5
- using System.Text;
6
- using UnityEditor;
7
- using UnityEngine;
8
-
9
- namespace TapSDK.Core.Standalone.Internal
10
- {
11
- public class NetUtils
12
- {
13
- // 随机生成一个 10 位的字符串
14
- public static string GenerateNonce()
15
- {
16
- string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
17
- char[] nonce = new char[10];
18
- for (int i = 0; i < 10; i++)
19
- {
20
- nonce[i] = chars[UnityEngine.Random.Range(0, chars.Length)];
21
- }
22
- return new string(nonce);
23
- }
24
-
25
- public static Dictionary<string, string> commonHeaders {
26
- get {
27
- var headers = new Dictionary<string, string> {
28
- { "User-Agent", $"{TapTapSDK.SDKPlatform}/{TapTapSDK.Version}" },
29
- { "X-Tap-Ts", TimeUtil.GetCurrentTime().ToString() },
30
- { "X-Tap-Nonce", NetUtils.GenerateNonce() },
31
- { "X-Tap-PN", "TapSDK" },
32
- { "X-Tap-Lang", Tracker.getServerLanguage() },
33
- { "X-Tap-Device-Id", Identity.DeviceId },
34
- { "X-Tap-Platform", "PC" },
35
- { "X-Tap-SDK-Module", "TapSDKCore" },
36
- { "X-Tap-SDK-Module-Version", TapTapSDK.Version },
37
- { "X-Tap-SDK-Artifact", "Unity" }
38
- };
39
-
40
- if (TapCoreStandalone.User.Id != null) {
41
- headers.Add("X-Tap-SDK-Game-User-Id", TapCoreStandalone.User.Id);
42
- }
43
-
44
- return headers;
45
- }
46
- }
47
- }
48
- }
@@ -1,30 +0,0 @@
1
- using System;
2
- using UnityEngine;
3
-
4
- namespace TapSDK.Core.Standalone.Internal {
5
-
6
- public static class TimeUtil
7
- {
8
- private static int timeOffset = 0;
9
-
10
- private static void SetTimeOffset(int offset)
11
- {
12
- timeOffset = offset;
13
- }
14
-
15
- // 获取当前时间的秒级时间戳
16
- public static int GetCurrentTime()
17
- {
18
- DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
19
- TimeSpan timeSpan = DateTime.UtcNow - epochStart;
20
- return (int)timeSpan.TotalSeconds + timeOffset;
21
- }
22
-
23
- public static void FixTime(int time)
24
- {
25
- Debug.Log("FixTime called with time: " + time);
26
- SetTimeOffset(time - (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);
27
- }
28
- }
29
-
30
- }