com.taptap.sdk.core 4.3.0-aplha.5
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/Editor/BuildTargetUtils.cs +14 -0
- package/Editor/BuildTargetUtils.cs.meta +11 -0
- package/Editor/LinkXMLGenerator.cs +70 -0
- package/Editor/LinkXMLGenerator.cs.meta +11 -0
- package/Editor/Plist.cs +954 -0
- package/Editor/Plist.cs.meta +3 -0
- package/Editor/SDKLinkProcessBuild.cs +119 -0
- package/Editor/SDKLinkProcessBuild.cs.meta +11 -0
- package/Editor/TapFileHelper.cs +168 -0
- package/Editor/TapFileHelper.cs.meta +3 -0
- package/Editor/TapSDK.Core.Editor.asmdef +15 -0
- package/Editor/TapSDK.Core.Editor.asmdef.meta +7 -0
- package/Editor/TapSDKCoreCompile.cs +284 -0
- package/Editor/TapSDKCoreCompile.cs.meta +3 -0
- package/Editor/TapSDKCoreIOSProcessor.cs +74 -0
- package/Editor/TapSDKCoreIOSProcessor.cs.meta +3 -0
- package/Editor/UI/ScrollViewEditor.cs +267 -0
- package/Editor/UI/ScrollViewEditor.cs.meta +12 -0
- package/Editor/UI/ScrollViewExEditor.cs +34 -0
- package/Editor/UI/ScrollViewExEditor.cs.meta +12 -0
- package/Editor/UI/TapSDK.UI.Editor.asmdef +17 -0
- package/Editor/UI/TapSDK.UI.Editor.asmdef.meta +7 -0
- package/Editor/UI.meta +9 -0
- package/Editor.meta +8 -0
- package/Mobile/Editor/NativeDependencies.xml +22 -0
- package/Mobile/Editor/NativeDependencies.xml.meta +7 -0
- package/Mobile/Editor/TapCommonMobileProcessBuild.cs +20 -0
- package/Mobile/Editor/TapCommonMobileProcessBuild.cs.meta +11 -0
- package/Mobile/Editor/TapSDK.Core.Mobile.Editor.asmdef +17 -0
- package/Mobile/Editor/TapSDK.Core.Mobile.Editor.asmdef.meta +7 -0
- package/Mobile/Editor.meta +8 -0
- package/Mobile/Runtime/AndroidNativeWrapper.cs +50 -0
- package/Mobile/Runtime/AndroidNativeWrapper.cs.meta +11 -0
- package/Mobile/Runtime/Bridge.cs +84 -0
- package/Mobile/Runtime/Bridge.cs.meta +11 -0
- package/Mobile/Runtime/BridgeAndroid.cs +73 -0
- package/Mobile/Runtime/BridgeAndroid.cs.meta +11 -0
- package/Mobile/Runtime/BridgeCallback.cs +35 -0
- package/Mobile/Runtime/BridgeCallback.cs.meta +11 -0
- package/Mobile/Runtime/BridgeIOS.cs +113 -0
- package/Mobile/Runtime/BridgeIOS.cs.meta +11 -0
- package/Mobile/Runtime/Command.cs +119 -0
- package/Mobile/Runtime/Command.cs.meta +11 -0
- package/Mobile/Runtime/Constants.cs +9 -0
- package/Mobile/Runtime/Constants.cs.meta +11 -0
- package/Mobile/Runtime/EngineBridgeInitializer.cs +33 -0
- package/Mobile/Runtime/EngineBridgeInitializer.cs.meta +11 -0
- package/Mobile/Runtime/IBridge.cs +15 -0
- package/Mobile/Runtime/IBridge.cs.meta +11 -0
- package/Mobile/Runtime/IOSNativeWrapper.cs +273 -0
- package/Mobile/Runtime/IOSNativeWrapper.cs.meta +11 -0
- package/Mobile/Runtime/Result.cs +37 -0
- package/Mobile/Runtime/Result.cs.meta +11 -0
- package/Mobile/Runtime/TapCoreMobile.cs +71 -0
- package/Mobile/Runtime/TapCoreMobile.cs.meta +11 -0
- package/Mobile/Runtime/TapEventMobile.cs +265 -0
- package/Mobile/Runtime/TapEventMobile.cs.meta +11 -0
- package/Mobile/Runtime/TapSDK.Core.Mobile.Runtime.asmdef +18 -0
- package/Mobile/Runtime/TapSDK.Core.Mobile.Runtime.asmdef.meta +7 -0
- package/Mobile/Runtime/TapUUID.cs +9 -0
- package/Mobile/Runtime/TapUUID.cs.meta +11 -0
- package/Mobile/Runtime.meta +8 -0
- package/Mobile.meta +8 -0
- package/Plugins/iOS.meta +8 -0
- package/Plugins.meta +8 -0
- package/Resources/Fonts/taptap-sdk-bold.ttf +0 -0
- package/Resources/Fonts/taptap-sdk-bold.ttf.meta +22 -0
- package/Resources/Fonts/taptap-sdk.ttf +0 -0
- package/Resources/Fonts/taptap-sdk.ttf.meta +21 -0
- package/Resources/Fonts.meta +8 -0
- package/Resources/Loading.prefab +260 -0
- package/Resources/Loading.prefab.meta +7 -0
- package/Resources/TapCommonTip.prefab +194 -0
- package/Resources/TapCommonTip.prefab.meta +7 -0
- package/Resources/TapCommonToastBlack.prefab +528 -0
- package/Resources/TapCommonToastBlack.prefab.meta +7 -0
- package/Resources/TapCommonToastWhite.prefab +411 -0
- package/Resources/TapCommonToastWhite.prefab.meta +7 -0
- package/Resources/TapSDKCommonTapIcon-v2.png +0 -0
- package/Resources/TapSDKCommonTapIcon-v2.png.meta +128 -0
- package/Resources/TapSDKCommonTapIcon.png +0 -0
- package/Resources/TapSDKCommonTapIcon.png.meta +128 -0
- package/Resources/TapSDKCommonToastBg.png +0 -0
- package/Resources/TapSDKCommonToastBg.png.meta +128 -0
- package/Resources/TapSDKConstantUIRoot.prefab +100 -0
- package/Resources/TapSDKConstantUIRoot.prefab.meta +7 -0
- package/Resources/TapSDKUIRoot.prefab +100 -0
- package/Resources/TapSDKUIRoot.prefab.meta +7 -0
- package/Resources/TapTapBtn_White.png +0 -0
- package/Resources/TapTapBtn_White.png.meta +128 -0
- package/Resources/TapTapBtn_White_2.png +0 -0
- package/Resources/TapTapBtn_White_2.png.meta +128 -0
- package/Resources/ToastBackground.png +0 -0
- package/Resources/ToastBackground.png.meta +128 -0
- package/Resources/detail_bg.png +0 -0
- package/Resources/detail_bg.png.meta +92 -0
- package/Resources/success.png +0 -0
- package/Resources/success.png.meta +128 -0
- package/Resources/taptap-bg.png +0 -0
- package/Resources/taptap-bg.png.meta +140 -0
- package/Resources/taptap-close.png +0 -0
- package/Resources/taptap-close.png.meta +146 -0
- package/Resources/taptap-router-v2.png +0 -0
- package/Resources/taptap-router-v2.png.meta +128 -0
- package/Resources/taptap-router.png +0 -0
- package/Resources/taptap-router.png.meta +146 -0
- package/Resources/taptap-sdk-refresh 1.png +0 -0
- package/Resources/taptap-sdk-refresh 1.png.meta +128 -0
- package/Resources/taptap-toast-error.png +0 -0
- package/Resources/taptap-toast-error.png.meta +128 -0
- package/Resources/taptap-toast-info.png +0 -0
- package/Resources/taptap-toast-info.png.meta +128 -0
- package/Resources/taptap-toast-success.png +0 -0
- package/Resources/taptap-toast-success.png.meta +128 -0
- package/Resources/taptap-toast-warning.png +0 -0
- package/Resources/taptap-toast-warning.png.meta +128 -0
- package/Resources.meta +8 -0
- package/Runtime/Internal/Http/TapHttpClient.cs +176 -0
- package/Runtime/Internal/Http/TapHttpClient.cs.meta +11 -0
- package/Runtime/Internal/Http/TapHttpUtils.cs +83 -0
- package/Runtime/Internal/Http/TapHttpUtils.cs.meta +11 -0
- package/Runtime/Internal/Http.meta +8 -0
- package/Runtime/Internal/Init/IInitTask.cs +18 -0
- package/Runtime/Internal/Init/IInitTask.cs.meta +11 -0
- package/Runtime/Internal/Init.meta +8 -0
- package/Runtime/Internal/Json/TapJsonConverter.cs +40 -0
- package/Runtime/Internal/Json/TapJsonConverter.cs.meta +11 -0
- package/Runtime/Internal/Json.meta +8 -0
- package/Runtime/Internal/Platform/ITapCorePlatform.cs +12 -0
- package/Runtime/Internal/Platform/ITapCorePlatform.cs.meta +11 -0
- package/Runtime/Internal/Platform/ITapEventPlatform.cs +37 -0
- package/Runtime/Internal/Platform/ITapEventPlatform.cs.meta +11 -0
- package/Runtime/Internal/Platform/PlatformTypeUtils.cs +46 -0
- package/Runtime/Internal/Platform/PlatformTypeUtils.cs.meta +11 -0
- package/Runtime/Internal/Platform.meta +8 -0
- package/Runtime/Internal/UI/Base/Const.cs +27 -0
- package/Runtime/Internal/UI/Base/Const.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/GraphicRaycasterBugFixed.cs +240 -0
- package/Runtime/Internal/UI/Base/GraphicRaycasterBugFixed.cs.meta +3 -0
- package/Runtime/Internal/UI/Base/LoadingPanelController.cs +29 -0
- package/Runtime/Internal/UI/Base/LoadingPanelController.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/MonoSingleton.cs +102 -0
- package/Runtime/Internal/UI/Base/MonoSingleton.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/Singleton.cs +29 -0
- package/Runtime/Internal/UI/Base/Singleton.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/TipPanelController.cs +45 -0
- package/Runtime/Internal/UI/Base/TipPanelController.cs.meta +3 -0
- package/Runtime/Internal/UI/Base/ToastBlackPanelController.cs +95 -0
- package/Runtime/Internal/UI/Base/ToastBlackPanelController.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/ToastWhitePanelController.cs +79 -0
- package/Runtime/Internal/UI/Base/ToastWhitePanelController.cs.meta +3 -0
- package/Runtime/Internal/UI/Base/UIManager.cs +724 -0
- package/Runtime/Internal/UI/Base/UIManager.cs.meta +11 -0
- package/Runtime/Internal/UI/Base.meta +8 -0
- package/Runtime/Internal/UI/BasePanel/BasePanelController.cs +385 -0
- package/Runtime/Internal/UI/BasePanel/BasePanelController.cs.meta +11 -0
- package/Runtime/Internal/UI/BasePanel.meta +8 -0
- package/Runtime/Internal/UI/Params/BasePanelConfig.cs +18 -0
- package/Runtime/Internal/UI/Params/BasePanelConfig.cs.meta +11 -0
- package/Runtime/Internal/UI/Params/IOpenPanelParameter.cs +7 -0
- package/Runtime/Internal/UI/Params/IOpenPanelParameter.cs.meta +11 -0
- package/Runtime/Internal/UI/Params.meta +8 -0
- package/Runtime/Internal/UI/ScrollViewEx/ObjPool/SimpleObjPool.cs +76 -0
- package/Runtime/Internal/UI/ScrollViewEx/ObjPool/SimpleObjPool.cs.meta +12 -0
- package/Runtime/Internal/UI/ScrollViewEx/ObjPool.meta +9 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollView.cs +828 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollView.cs.meta +12 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollViewEx.cs +245 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollViewEx.cs.meta +12 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView.meta +9 -0
- package/Runtime/Internal/UI/ScrollViewEx.meta +8 -0
- package/Runtime/Internal/UI.meta +8 -0
- package/Runtime/Internal/Utils/BridgeUtils.cs +29 -0
- package/Runtime/Internal/Utils/BridgeUtils.cs.meta +11 -0
- package/Runtime/Internal/Utils/ImageUtils.cs +147 -0
- package/Runtime/Internal/Utils/ImageUtils.cs.meta +11 -0
- package/Runtime/Internal/Utils/TapLoom.cs +155 -0
- package/Runtime/Internal/Utils/TapLoom.cs.meta +11 -0
- package/Runtime/Internal/Utils/UrlUtils.cs +34 -0
- package/Runtime/Internal/Utils/UrlUtils.cs.meta +11 -0
- package/Runtime/Internal/Utils.meta +8 -0
- package/Runtime/Internal.meta +8 -0
- package/Runtime/Public/DataStorage.cs +141 -0
- package/Runtime/Public/DataStorage.cs.meta +11 -0
- package/Runtime/Public/ITapPropertiesProxy.cs +6 -0
- package/Runtime/Public/ITapPropertiesProxy.cs.meta +11 -0
- package/Runtime/Public/Json.cs +636 -0
- package/Runtime/Public/Json.cs.meta +11 -0
- package/Runtime/Public/Log/TapLogLevel.cs +7 -0
- package/Runtime/Public/Log/TapLogLevel.cs.meta +11 -0
- package/Runtime/Public/Log/TapLogger.cs +48 -0
- package/Runtime/Public/Log/TapLogger.cs.meta +11 -0
- package/Runtime/Public/Log.meta +8 -0
- package/Runtime/Public/Platform.cs +27 -0
- package/Runtime/Public/Platform.cs.meta +11 -0
- package/Runtime/Public/RegionType.cs +8 -0
- package/Runtime/Public/RegionType.cs.meta +11 -0
- package/Runtime/Public/SafeDictionary.cs +27 -0
- package/Runtime/Public/SafeDictionary.cs.meta +11 -0
- package/Runtime/Public/TapError.cs +62 -0
- package/Runtime/Public/TapError.cs.meta +11 -0
- package/Runtime/Public/TapErrorCode.cs +44 -0
- package/Runtime/Public/TapErrorCode.cs.meta +11 -0
- package/Runtime/Public/TapException.cs +24 -0
- package/Runtime/Public/TapException.cs.meta +11 -0
- package/Runtime/Public/TapLanguage.cs +21 -0
- package/Runtime/Public/TapLanguage.cs.meta +11 -0
- package/Runtime/Public/TapLocalizeManager.cs +128 -0
- package/Runtime/Public/TapLocalizeManager.cs.meta +11 -0
- package/Runtime/Public/TapTapEvent.cs +93 -0
- package/Runtime/Public/TapTapEvent.cs.meta +11 -0
- package/Runtime/Public/TapTapSDK.cs +96 -0
- package/Runtime/Public/TapTapSDK.cs.meta +11 -0
- package/Runtime/Public/TapTapSDKCoreOptions.cs +104 -0
- package/Runtime/Public/TapTapSDKCoreOptions.cs.meta +11 -0
- package/Runtime/Public.meta +8 -0
- package/Runtime/TapSDK.Core.Runtime.asmdef +3 -0
- package/Runtime/TapSDK.Core.Runtime.asmdef.meta +7 -0
- package/Runtime.meta +8 -0
- package/Standalone/Editor/TapCoreStandaloneProcessBuild.cs +20 -0
- package/Standalone/Editor/TapCoreStandaloneProcessBuild.cs.meta +11 -0
- package/Standalone/Editor/TapSDK.Core.Standalone.Editor.asmdef +17 -0
- package/Standalone/Editor/TapSDK.Core.Standalone.Editor.asmdef.meta +7 -0
- package/Standalone/Editor.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/Info.plist +46 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/Info.plist.meta +7 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/MacOS/TapDBDeviceInfo +0 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/MacOS/TapDBDeviceInfo.meta +7 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/MacOS.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/_CodeSignature/CodeResources +115 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/_CodeSignature/CodeResources.meta +7 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/_CodeSignature.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle.meta +33 -0
- package/Standalone/Plugins/macOS.meta +8 -0
- package/Standalone/Plugins.meta +8 -0
- package/Standalone/Runtime/Internal/Constants.cs +37 -0
- package/Standalone/Runtime/Internal/Constants.cs.meta +11 -0
- package/Standalone/Runtime/Internal/DeviceInfo.cs +152 -0
- package/Standalone/Runtime/Internal/DeviceInfo.cs.meta +11 -0
- package/Standalone/Runtime/Internal/EventSender.cs +239 -0
- package/Standalone/Runtime/Internal/EventSender.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http/HttpClient.cs +211 -0
- package/Standalone/Runtime/Internal/Http/HttpClient.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http/NetUtils.cs +48 -0
- package/Standalone/Runtime/Internal/Http/NetUtils.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http/TimeUtil.cs +30 -0
- package/Standalone/Runtime/Internal/Http/TimeUtil.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http.meta +8 -0
- package/Standalone/Runtime/Internal/Identity.cs +43 -0
- package/Standalone/Runtime/Internal/Identity.cs.meta +11 -0
- package/Standalone/Runtime/Internal/PlayRecorder.cs +53 -0
- package/Standalone/Runtime/Internal/PlayRecorder.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Prefs.cs +85 -0
- package/Standalone/Runtime/Internal/Prefs.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Tracker.cs +318 -0
- package/Standalone/Runtime/Internal/Tracker.cs.meta +11 -0
- package/Standalone/Runtime/Internal/User.cs +51 -0
- package/Standalone/Runtime/Internal/User.cs.meta +11 -0
- package/Standalone/Runtime/Internal.meta +8 -0
- package/Standalone/Runtime/Public/EventManager.cs +41 -0
- package/Standalone/Runtime/Public/EventManager.cs.meta +11 -0
- package/Standalone/Runtime/Public/TapCoreStandalone.cs +197 -0
- package/Standalone/Runtime/Public/TapCoreStandalone.cs.meta +11 -0
- package/Standalone/Runtime/Public/TapEventStandalone.cs +281 -0
- package/Standalone/Runtime/Public/TapEventStandalone.cs.meta +11 -0
- package/Standalone/Runtime/Public.meta +8 -0
- package/Standalone/Runtime/TapSDK.Core.Standalone.Runtime.asmdef +21 -0
- package/Standalone/Runtime/TapSDK.Core.Standalone.Runtime.asmdef.meta +7 -0
- package/Standalone/Runtime.meta +8 -0
- package/Standalone.meta +8 -0
- package/package.json +8 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Runtime.InteropServices;
|
|
3
|
+
using System.Globalization;
|
|
4
|
+
using System.Diagnostics;
|
|
5
|
+
using System.Collections;
|
|
6
|
+
using System.Collections.Generic;
|
|
7
|
+
using System.Net.NetworkInformation;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
namespace TapSDK.Core.Standalone.Internal {
|
|
11
|
+
public class DeviceInfo {
|
|
12
|
+
|
|
13
|
+
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
|
|
14
|
+
[DllImport("TapDBDeviceInfo", CallingConvention = CallingConvention.Cdecl)]
|
|
15
|
+
private static extern IntPtr GetDeviceLanguage();
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
public static string GetLanguage() {
|
|
19
|
+
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
|
|
20
|
+
return Marshal.PtrToStringAnsi(GetDeviceLanguage());
|
|
21
|
+
#else
|
|
22
|
+
return CultureInfo.CurrentUICulture.IetfLanguageTag;
|
|
23
|
+
#endif
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
|
|
27
|
+
[DllImport("kernel32.dll")]
|
|
28
|
+
static extern IntPtr GetCurrentProcess();
|
|
29
|
+
|
|
30
|
+
[DllImport("kernel32.dll")]
|
|
31
|
+
static extern uint GetProcessTimes(IntPtr processHandle,
|
|
32
|
+
out long creationTime,
|
|
33
|
+
out long exitTime,
|
|
34
|
+
out long kernelTime,
|
|
35
|
+
out long userTime);
|
|
36
|
+
|
|
37
|
+
static DateTime GetProcessStartTime()
|
|
38
|
+
{
|
|
39
|
+
IntPtr processHandle = GetCurrentProcess();
|
|
40
|
+
long creationTime;
|
|
41
|
+
GetProcessTimes(processHandle,
|
|
42
|
+
out creationTime,
|
|
43
|
+
out _,
|
|
44
|
+
out _,
|
|
45
|
+
out _);
|
|
46
|
+
|
|
47
|
+
return DateTime.FromFileTime(creationTime);
|
|
48
|
+
}
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
//安全组提供的设备识别 ID 算法,用于后续数据串联
|
|
52
|
+
public static string GetLaunchUniqueID()
|
|
53
|
+
{
|
|
54
|
+
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
|
|
55
|
+
// 获取当前进程对象
|
|
56
|
+
Process currentProcess = Process.GetCurrentProcess();
|
|
57
|
+
// 获取进程启动时间
|
|
58
|
+
DateTime startTime = GetProcessStartTime();
|
|
59
|
+
return toMd5(startTime.ToFileTime().ToString() + "-" + currentProcess.Id.ToString());
|
|
60
|
+
#else
|
|
61
|
+
return "";
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public static void GetMacAddress(out string macAddressList, out string firstMacAddress)
|
|
67
|
+
{
|
|
68
|
+
List<string> mac_addrs = new List<string>();
|
|
69
|
+
|
|
70
|
+
try
|
|
71
|
+
{
|
|
72
|
+
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
|
|
73
|
+
foreach (NetworkInterface adapter in nics)
|
|
74
|
+
{
|
|
75
|
+
string physicalAddress = adapter.GetPhysicalAddress().ToString();
|
|
76
|
+
if (string.IsNullOrEmpty(physicalAddress))
|
|
77
|
+
continue;
|
|
78
|
+
|
|
79
|
+
physicalAddress = $"\"{physicalAddress}\"";
|
|
80
|
+
if (mac_addrs.IndexOf(physicalAddress) == -1)
|
|
81
|
+
mac_addrs.Add(physicalAddress);
|
|
82
|
+
}
|
|
83
|
+
// sort
|
|
84
|
+
mac_addrs.Sort();
|
|
85
|
+
}
|
|
86
|
+
catch (Exception e)
|
|
87
|
+
{
|
|
88
|
+
UnityEngine.Debug.Log("GetMacAddress Exception " + e.Message);
|
|
89
|
+
}
|
|
90
|
+
macAddressList = $"[{string.Join(",", mac_addrs)}]";
|
|
91
|
+
firstMacAddress = mac_addrs.Count > 0 ? mac_addrs[0].Replace("\"", "") : string.Empty;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private static string toMd5(string data)
|
|
95
|
+
{
|
|
96
|
+
byte[] buffer = System.Text.Encoding.Default.GetBytes(data);
|
|
97
|
+
try
|
|
98
|
+
{
|
|
99
|
+
System.Security.Cryptography.MD5CryptoServiceProvider chk = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
|
100
|
+
byte[] some = chk.ComputeHash(buffer);
|
|
101
|
+
string ret = "";
|
|
102
|
+
foreach(byte a in some)
|
|
103
|
+
{
|
|
104
|
+
if (a < 16)
|
|
105
|
+
ret += "0" + a.ToString("X");
|
|
106
|
+
else
|
|
107
|
+
ret += a.ToString("X");
|
|
108
|
+
}
|
|
109
|
+
return ret.ToLower();
|
|
110
|
+
}
|
|
111
|
+
catch
|
|
112
|
+
{
|
|
113
|
+
throw;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public static string RAM
|
|
118
|
+
{
|
|
119
|
+
get {
|
|
120
|
+
return (SystemInfo.systemMemorySize * 1024L * 1024L).ToString();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 获取系统的 ROM 存储容量,单位为 Byte
|
|
125
|
+
public static string ROM
|
|
126
|
+
{
|
|
127
|
+
get {
|
|
128
|
+
string path = Application.persistentDataPath;
|
|
129
|
+
if (string.IsNullOrEmpty(path))
|
|
130
|
+
return "0";
|
|
131
|
+
|
|
132
|
+
try
|
|
133
|
+
{
|
|
134
|
+
System.IO.DriveInfo drive = new System.IO.DriveInfo(path);
|
|
135
|
+
return drive.TotalSize.ToString();
|
|
136
|
+
}
|
|
137
|
+
catch (Exception e)
|
|
138
|
+
{
|
|
139
|
+
UnityEngine.Debug.Log("GetROMInByte Exception " + e.Message);
|
|
140
|
+
return "0";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public static string Local
|
|
146
|
+
{
|
|
147
|
+
get {
|
|
148
|
+
return CultureInfo.CurrentCulture.Name.Replace('-', '_');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.IO;
|
|
6
|
+
using System.Linq;
|
|
7
|
+
using System.Text;
|
|
8
|
+
using System.Threading;
|
|
9
|
+
using System.Threading.Tasks;
|
|
10
|
+
using UnityEngine;
|
|
11
|
+
using UnityEngine.Networking;
|
|
12
|
+
|
|
13
|
+
namespace TapSDK.Core.Standalone.Internal {
|
|
14
|
+
public class EventSender : MonoBehaviour
|
|
15
|
+
{
|
|
16
|
+
private const string EventFilePath = "events.json";
|
|
17
|
+
private string persistentDataPath = Application.persistentDataPath;
|
|
18
|
+
|
|
19
|
+
private Queue<Dictionary<string, object>> eventQueue = new Queue<Dictionary<string, object>>();
|
|
20
|
+
private HttpClient httpClient;
|
|
21
|
+
private const int MaxEvents = 50;
|
|
22
|
+
private const int MaxBatchSize = 200;
|
|
23
|
+
private const float SendInterval = 15f;
|
|
24
|
+
private Timer timer;
|
|
25
|
+
private DateTime lastSendTime;
|
|
26
|
+
|
|
27
|
+
private int QueueCount => eventQueue.Count;
|
|
28
|
+
|
|
29
|
+
public EventSender()
|
|
30
|
+
{
|
|
31
|
+
// 设置计时器
|
|
32
|
+
timer = new Timer(OnTimerElapsed, null, TimeSpan.Zero, TimeSpan.FromSeconds(SendInterval));
|
|
33
|
+
lastSendTime = DateTime.Now;
|
|
34
|
+
|
|
35
|
+
// 初始化 HttpClient
|
|
36
|
+
var header = new Dictionary<string, string>
|
|
37
|
+
{
|
|
38
|
+
{ "User-Agent", $"{TapTapSDK.SDKPlatform}/{TapTapSDK.SDKVersion}" }
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var coreOptions = TapCoreStandalone.coreOptions;
|
|
42
|
+
if(coreOptions.region == TapTapRegionType.CN) {
|
|
43
|
+
HttpClientConfig config = new HttpClientConfig(Constants.SERVER_URL_BJ, header);
|
|
44
|
+
httpClient = new HttpClient(config);
|
|
45
|
+
} else {
|
|
46
|
+
HttpClientConfig config = new HttpClientConfig(Constants.SERVER_URL_SG, header);
|
|
47
|
+
httpClient = new HttpClient(config);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 加载未发送的事件
|
|
51
|
+
LoadEvents();
|
|
52
|
+
SendEventsAsync(null);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async void SendEventsAsync(Action onSendComplete)
|
|
56
|
+
{
|
|
57
|
+
if (eventQueue.Count == 0)
|
|
58
|
+
{
|
|
59
|
+
onSendComplete?.Invoke();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var eventsToSend = new List<Dictionary<string, object>>();
|
|
64
|
+
for (int i = 0; i < MaxBatchSize && eventQueue.Count > 0; i++)
|
|
65
|
+
{
|
|
66
|
+
eventsToSend.Add(eventQueue.Dequeue());
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var body = new Dictionary<string, object> {
|
|
70
|
+
{ "data", eventsToSend }
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
var resonse = await httpClient.Post("batch", body);
|
|
74
|
+
|
|
75
|
+
// 判断是否请求成功
|
|
76
|
+
if (resonse == null)
|
|
77
|
+
{
|
|
78
|
+
// 将事件重新添加到队列
|
|
79
|
+
foreach (var eventParams in eventsToSend)
|
|
80
|
+
{
|
|
81
|
+
eventQueue.Enqueue(eventParams);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else
|
|
85
|
+
{
|
|
86
|
+
Debug.Log("Events sent successfully");
|
|
87
|
+
}
|
|
88
|
+
onSendComplete?.Invoke();
|
|
89
|
+
SaveEvents();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public void Send(Dictionary<string, object> eventParams)
|
|
93
|
+
{
|
|
94
|
+
// 将事件添加到队列
|
|
95
|
+
eventQueue.Enqueue(eventParams);
|
|
96
|
+
SaveEvents();
|
|
97
|
+
|
|
98
|
+
// 检查队列大小
|
|
99
|
+
if (QueueCount >= MaxEvents)
|
|
100
|
+
{
|
|
101
|
+
SendEvents();
|
|
102
|
+
ResetTimer();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private void OnTimerElapsed(object state)
|
|
107
|
+
{
|
|
108
|
+
var offset = (DateTime.Now - lastSendTime).TotalSeconds;
|
|
109
|
+
if (offset >= SendInterval)
|
|
110
|
+
{
|
|
111
|
+
SendEvents();
|
|
112
|
+
ResetTimer();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
private void ResetTimer()
|
|
118
|
+
{
|
|
119
|
+
timer.Change(TimeSpan.FromSeconds(SendInterval), TimeSpan.FromSeconds(SendInterval));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private void LoadEvents()
|
|
123
|
+
{
|
|
124
|
+
string filePath = Path.Combine(persistentDataPath, EventFilePath);
|
|
125
|
+
if (File.Exists(filePath))
|
|
126
|
+
{
|
|
127
|
+
string jsonData = File.ReadAllText(filePath);
|
|
128
|
+
if (string.IsNullOrEmpty(jsonData))
|
|
129
|
+
{
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
var savedEvents = ConvertToListOfDictionaries(Json.Deserialize(jsonData));
|
|
134
|
+
if (savedEvents == null)
|
|
135
|
+
{
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
foreach (var eventParams in savedEvents)
|
|
139
|
+
{
|
|
140
|
+
eventQueue.Enqueue(eventParams);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private void SaveEvents()
|
|
146
|
+
{
|
|
147
|
+
try
|
|
148
|
+
{
|
|
149
|
+
if (eventQueue == null)
|
|
150
|
+
{
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
var eventList = eventQueue.ToList();
|
|
155
|
+
string jsonData = Json.Serialize(eventList);
|
|
156
|
+
|
|
157
|
+
if (string.IsNullOrEmpty(EventFilePath))
|
|
158
|
+
{
|
|
159
|
+
Debug.LogError("EventFilePath is null or empty");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
string filePath = Path.Combine(persistentDataPath, EventFilePath);
|
|
164
|
+
|
|
165
|
+
if (string.IsNullOrEmpty(filePath))
|
|
166
|
+
{
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
File.WriteAllText(filePath, jsonData);
|
|
171
|
+
}
|
|
172
|
+
catch (Exception ex)
|
|
173
|
+
{
|
|
174
|
+
Debug.LogError("SaveEvents Exception - " + ex.Message);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
public void SendEvents()
|
|
179
|
+
{
|
|
180
|
+
SendEventsAsync(() => lastSendTime = DateTime.Now);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private Dictionary<string, object> ConvertToDictionary(Dictionary<string, object> original)
|
|
184
|
+
{
|
|
185
|
+
var result = new Dictionary<string, object>();
|
|
186
|
+
foreach (var keyValuePair in original)
|
|
187
|
+
{
|
|
188
|
+
if (keyValuePair.Value is Dictionary<string, object> nestedDictionary)
|
|
189
|
+
{
|
|
190
|
+
result[keyValuePair.Key] = ConvertToDictionary(nestedDictionary);
|
|
191
|
+
}
|
|
192
|
+
else if (keyValuePair.Value is List<object> nestedList)
|
|
193
|
+
{
|
|
194
|
+
result[keyValuePair.Key] = ConvertToListOfDictionaries(nestedList);
|
|
195
|
+
}
|
|
196
|
+
else
|
|
197
|
+
{
|
|
198
|
+
result[keyValuePair.Key] = keyValuePair.Value;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
private List<Dictionary<string, object>> ConvertToListOfDictionaries(object deserializedData)
|
|
204
|
+
{
|
|
205
|
+
if (deserializedData is List<object> list)
|
|
206
|
+
{
|
|
207
|
+
var result = new List<Dictionary<string, object>>();
|
|
208
|
+
foreach (var item in list)
|
|
209
|
+
{
|
|
210
|
+
if (item is Dictionary<string, object> dictionary)
|
|
211
|
+
{
|
|
212
|
+
result.Add(ConvertToDictionary(dictionary));
|
|
213
|
+
}
|
|
214
|
+
else
|
|
215
|
+
{
|
|
216
|
+
return null; // 数据格式不匹配
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
return null; // 数据格式不匹配
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
[Serializable]
|
|
225
|
+
private class Serialization<T>
|
|
226
|
+
{
|
|
227
|
+
public List<T> items;
|
|
228
|
+
public Serialization(List<T> items)
|
|
229
|
+
{
|
|
230
|
+
this.items = items;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
public List<T> ToList()
|
|
234
|
+
{
|
|
235
|
+
return items;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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.SDKVersion}" },
|
|
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.SDKVersion },
|
|
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
|
+
}
|