com.taptap.sdk.login 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/Mobile/Editor/NativeDependencies.xml +20 -0
- package/Mobile/Editor/NativeDependencies.xml.meta +7 -0
- package/Mobile/Editor/TapLoginIOSProcessor.cs +91 -0
- package/Mobile/Editor/TapLoginIOSProcessor.cs.meta +11 -0
- package/Mobile/Editor/TapLoginMobileProcessBuild.cs +20 -0
- package/Mobile/Editor/TapLoginMobileProcessBuild.cs.meta +11 -0
- package/Mobile/Editor/TapSDK.Login.Mobile.Editor.asmdef +17 -0
- package/Mobile/Editor/TapSDK.Login.Mobile.Editor.asmdef.meta +7 -0
- package/Mobile/Editor.meta +8 -0
- package/Mobile/Runtime/AccountWrapper.cs +32 -0
- package/Mobile/Runtime/AccountWrapper.cs.meta +3 -0
- package/Mobile/Runtime/TapSDK.Login.Mobile.Runtime.asmdef +20 -0
- package/Mobile/Runtime/TapSDK.Login.Mobile.Runtime.asmdef.meta +7 -0
- package/Mobile/Runtime/TapTapLoginImpl.cs +81 -0
- package/Mobile/Runtime/TapTapLoginImpl.cs.meta +3 -0
- package/Mobile/Runtime.meta +8 -0
- package/Mobile.meta +8 -0
- package/Plugins/iOS/TapTapSDKLoginAppDelegate.mm +40 -0
- package/Plugins/iOS/TapTapSDKLoginAppDelegate.mm.meta +37 -0
- package/Plugins/iOS.meta +8 -0
- package/Plugins/zxing.unity.dll +0 -0
- package/Plugins/zxing.unity.dll.meta +33 -0
- package/Plugins.meta +8 -0
- package/Runtime/Internal/ITapTapLoginPlatform.cs +15 -0
- package/Runtime/Internal/ITapTapLoginPlatform.cs.meta +3 -0
- package/Runtime/Internal/Init/LoginInitTask.cs +20 -0
- package/Runtime/Internal/Init/LoginInitTask.cs.meta +11 -0
- package/Runtime/Internal/Init.meta +8 -0
- package/Runtime/Internal/Region.cs +98 -0
- package/Runtime/Internal/Region.cs.meta +11 -0
- package/Runtime/Internal/TapTapLoginManager.cs +38 -0
- package/Runtime/Internal/TapTapLoginManager.cs.meta +3 -0
- package/Runtime/Internal.meta +8 -0
- package/Runtime/Public/AccessToken.cs +83 -0
- package/Runtime/Public/AccessToken.cs.meta +11 -0
- package/Runtime/Public/Profile.cs +51 -0
- package/Runtime/Public/Profile.cs.meta +11 -0
- package/Runtime/Public/TapTapAccount.cs +70 -0
- package/Runtime/Public/TapTapAccount.cs.meta +3 -0
- package/Runtime/Public/TapTapLogin.cs +39 -0
- package/Runtime/Public/TapTapLogin.cs.meta +3 -0
- package/Runtime/Public/TapTapSdk.cs +26 -0
- package/Runtime/Public/TapTapSdk.cs.meta +11 -0
- package/Runtime/Public.meta +8 -0
- package/Runtime/TapSDK.Login.Runtime.asmdef +15 -0
- package/Runtime/TapSDK.Login.Runtime.asmdef.meta +7 -0
- package/Runtime.meta +8 -0
- package/Standalone/Editor/TapLoginStandaloneProcessBuild.cs +22 -0
- package/Standalone/Editor/TapLoginStandaloneProcessBuild.cs.meta +11 -0
- package/Standalone/Editor/TapSDK.Login.Standalone.Editor.asmdef +17 -0
- package/Standalone/Editor/TapSDK.Login.Standalone.Editor.asmdef.meta +7 -0
- package/Standalone/Editor.meta +8 -0
- package/Standalone/Resources/Prefabs/TapLogin/LoginPanel.prefab +811 -0
- package/Standalone/Resources/Prefabs/TapLogin/LoginPanel.prefab.meta +8 -0
- package/Standalone/Resources/Prefabs/TapLogin/LoginWithPermissionPanel.prefab +820 -0
- package/Standalone/Resources/Prefabs/TapLogin/LoginWithPermissionPanel.prefab.meta +8 -0
- package/Standalone/Resources/Prefabs/TapLogin/PermissionItem.prefab +314 -0
- package/Standalone/Resources/Prefabs/TapLogin/PermissionItem.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin/QRCodeContainer.prefab +1501 -0
- package/Standalone/Resources/Prefabs/TapLogin/QRCodeContainer.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin/Tips.prefab +286 -0
- package/Standalone/Resources/Prefabs/TapLogin/Tips.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin/TopBar.prefab +485 -0
- package/Standalone/Resources/Prefabs/TapLogin/TopBar.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin/WebContainer.prefab +514 -0
- package/Standalone/Resources/Prefabs/TapLogin/WebContainer.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin/WebWithPermissionContainer.prefab +988 -0
- package/Standalone/Resources/Prefabs/TapLogin/WebWithPermissionContainer.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapLogin.meta +8 -0
- package/Standalone/Resources/Prefabs/TapTapSdkWindow.prefab +175 -0
- package/Standalone/Resources/Prefabs/TapTapSdkWindow.prefab.meta +8 -0
- package/Standalone/Resources/Prefabs.meta +8 -0
- package/Standalone/Resources/Sprites/taptap-client-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-client-bg.png.meta +92 -0
- package/Standalone/Resources/Sprites/taptap-divider.png +0 -0
- package/Standalone/Resources/Sprites/taptap-divider.png.meta +146 -0
- package/Standalone/Resources/Sprites/taptap-login-android-client.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-android-client.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-checked-v2.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-checked-v2.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-checked.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-checked.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-unchecked.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-auth-unchecked.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-button-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-button-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-confirm-triangle.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-confirm-triangle.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-ios-client.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-ios-client.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-login-tips-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-login-tips-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-logo.png +0 -0
- package/Standalone/Resources/Sprites/taptap-logo.png.meta +130 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-error.png +0 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-error.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-info.png +0 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-info.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-success.png +0 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-success.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-warning.png +0 -0
- package/Standalone/Resources/Sprites/taptap-scan-tips-warning.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-cancel.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-cancel.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-guide.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-guide.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-logo.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-logo.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-qrcode-bg-grey.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-qrcode-bg-grey.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-qrcode-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-qrcode-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-refresh-btn-bg.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-refresh-btn-bg.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-sdk-refresh.png +0 -0
- package/Standalone/Resources/Sprites/taptap-sdk-refresh.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-tap-log-v2.png +0 -0
- package/Standalone/Resources/Sprites/taptap-tap-log-v2.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-tap-logo.png +0 -0
- package/Standalone/Resources/Sprites/taptap-tap-logo.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-web-login-icon-v2.png +0 -0
- package/Standalone/Resources/Sprites/taptap-web-login-icon-v2.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-web-login-icon.png +0 -0
- package/Standalone/Resources/Sprites/taptap-web-login-icon.png.meta +128 -0
- package/Standalone/Resources/Sprites/taptap-web-login.png +0 -0
- package/Standalone/Resources/Sprites/taptap-web-login.png.meta +146 -0
- package/Standalone/Resources/Sprites.meta +8 -0
- package/Standalone/Resources.meta +8 -0
- package/Standalone/Runtime/Internal/ContainerWindow.cs +67 -0
- package/Standalone/Runtime/Internal/ContainerWindow.cs.meta +11 -0
- package/Standalone/Runtime/Internal/LoginLanguage.cs +1117 -0
- package/Standalone/Runtime/Internal/LoginLanguage.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Net.cs +291 -0
- package/Standalone/Runtime/Internal/Net.cs.meta +11 -0
- package/Standalone/Runtime/Internal/QRCodeWindow.cs +776 -0
- package/Standalone/Runtime/Internal/QRCodeWindow.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI.cs +22 -0
- package/Standalone/Runtime/Internal/UI.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UIAnimator.cs +77 -0
- package/Standalone/Runtime/Internal/UIAnimator.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UIBase.cs +27 -0
- package/Standalone/Runtime/Internal/UIBase.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UIElement.cs +185 -0
- package/Standalone/Runtime/Internal/UIElement.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UIManager.cs +100 -0
- package/Standalone/Runtime/Internal/UIManager.cs.meta +11 -0
- package/Standalone/Runtime/Internal/WebLoginRequestManager.cs +185 -0
- package/Standalone/Runtime/Internal/WebLoginRequestManager.cs.meta +11 -0
- package/Standalone/Runtime/Internal.meta +8 -0
- package/Standalone/Runtime/Internal2/AccountManager.cs +87 -0
- package/Standalone/Runtime/Internal2/AccountManager.cs.meta +3 -0
- package/Standalone/Runtime/Internal2/AuthorizationProviderImpl.cs +13 -0
- package/Standalone/Runtime/Internal2/AuthorizationProviderImpl.cs.meta +3 -0
- package/Standalone/Runtime/Internal2/Http/LoginHttpClient.cs +139 -0
- package/Standalone/Runtime/Internal2/Http/LoginHttpClient.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/Http/Response/ErrorResponse.cs +16 -0
- package/Standalone/Runtime/Internal2/Http/Response/ErrorResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/Http/Response/ProfileResponse.cs +28 -0
- package/Standalone/Runtime/Internal2/Http/Response/ProfileResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/Http/Response/QRCodeResponse.cs +22 -0
- package/Standalone/Runtime/Internal2/Http/Response/QRCodeResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/Http/Response/TokenResponse.cs +33 -0
- package/Standalone/Runtime/Internal2/Http/Response/TokenResponse.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/Http/Response.meta +8 -0
- package/Standalone/Runtime/Internal2/Http.meta +8 -0
- package/Standalone/Runtime/Internal2/LoginService.cs +127 -0
- package/Standalone/Runtime/Internal2/LoginService.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/QRCodeUtils.cs +50 -0
- package/Standalone/Runtime/Internal2/QRCodeUtils.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/TapLoginStandaloneImpl.cs +181 -0
- package/Standalone/Runtime/Internal2/TapLoginStandaloneImpl.cs.meta +3 -0
- package/Standalone/Runtime/Internal2/UI/ClientButtonListener.cs +20 -0
- package/Standalone/Runtime/Internal2/UI/ClientButtonListener.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/UI/LoginPanelController.cs +72 -0
- package/Standalone/Runtime/Internal2/UI/LoginPanelController.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/UI/QRCodeController.cs +180 -0
- package/Standalone/Runtime/Internal2/UI/QRCodeController.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/UI/TitleController.cs +20 -0
- package/Standalone/Runtime/Internal2/UI/TitleController.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/UI/WebController.cs +125 -0
- package/Standalone/Runtime/Internal2/UI/WebController.cs.meta +11 -0
- package/Standalone/Runtime/Internal2/UI.meta +8 -0
- package/Standalone/Runtime/Internal2.meta +8 -0
- package/Standalone/Runtime/Public/IAuthorizationProvider.cs +9 -0
- package/Standalone/Runtime/Public/IAuthorizationProvider.cs.meta +3 -0
- package/Standalone/Runtime/Public/IComplianceProvider.cs +7 -0
- package/Standalone/Runtime/Public/IComplianceProvider.cs.meta +3 -0
- package/Standalone/Runtime/Public/TapTapLoginStandalone.cs +38 -0
- package/Standalone/Runtime/Public/TapTapLoginStandalone.cs.meta +3 -0
- package/Standalone/Runtime/Public.meta +8 -0
- package/Standalone/Runtime/TapSDK.Login.Standalone.Runtime.asmdef +24 -0
- package/Standalone/Runtime/TapSDK.Login.Standalone.Runtime.asmdef.meta +7 -0
- package/Standalone/Runtime.meta +8 -0
- package/Standalone.meta +8 -0
- package/package.json +11 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Collections.Specialized;
|
|
5
|
+
using System.Text;
|
|
6
|
+
using System.Text.RegularExpressions;
|
|
7
|
+
using TapSDK.Core;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
namespace TapSDK.Login.Internal
|
|
11
|
+
{
|
|
12
|
+
public class Net : MonoBehaviour
|
|
13
|
+
{
|
|
14
|
+
public delegate void Action();
|
|
15
|
+
|
|
16
|
+
// ReSharper disable Unity.PerformanceAnalysis
|
|
17
|
+
public void PostAsync(string url, Dictionary<string, string> queryParams, Dictionary<string, string> formParams, Action<string> methodForResult, Action<int, string> methodForError)
|
|
18
|
+
{
|
|
19
|
+
if (string.IsNullOrEmpty(url))
|
|
20
|
+
{
|
|
21
|
+
methodForError(-1, "empty url");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
StartCoroutine(Post(url, queryParams, formParams, methodForResult, methodForError));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ReSharper disable Unity.PerformanceAnalysis
|
|
28
|
+
public void GetAsync(string url, string authorization, Dictionary<string, string> queryParams, Action<string> methodForResult, Action<int, string> methodForError)
|
|
29
|
+
{
|
|
30
|
+
if (string.IsNullOrEmpty(url))
|
|
31
|
+
{
|
|
32
|
+
methodForError(-1, "empty url");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
StartCoroutine(Get(url, authorization, queryParams, methodForResult, methodForError));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ReSharper disable Unity.PerformanceAnalysis
|
|
39
|
+
private IEnumerator Get(string url, string authorization, Dictionary<string, string> queryParams, Action<string> methodForResult, Action<int, string> methodForError)
|
|
40
|
+
{
|
|
41
|
+
string baseUrl;
|
|
42
|
+
Dictionary<string, string> finalQueryParams = queryParams ?? new Dictionary<string, string>();
|
|
43
|
+
NameValueCollection collection = new NameValueCollection();
|
|
44
|
+
ParseUrl(url, out baseUrl, out collection);
|
|
45
|
+
foreach (string key in collection.AllKeys)
|
|
46
|
+
{
|
|
47
|
+
foreach (string value in collection.GetValues(key))
|
|
48
|
+
{
|
|
49
|
+
finalQueryParams.Add(key, value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
string finalUrl;
|
|
53
|
+
if (finalQueryParams.Count == 0)
|
|
54
|
+
{
|
|
55
|
+
finalUrl = baseUrl;
|
|
56
|
+
}
|
|
57
|
+
else
|
|
58
|
+
{
|
|
59
|
+
finalUrl = baseUrl + "?" + DictToQueryString(finalQueryParams);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Dictionary<string, string> headers = new Dictionary<string, string>();
|
|
64
|
+
headers.Add("User-Agent", "TapTapUnitySDK/" + TapTapSdk.Version + " " + "UnityPlayer/" + Application.unityVersion);
|
|
65
|
+
headers.Add("Authorization", authorization);
|
|
66
|
+
WWW w = new WWW(finalUrl, null, headers);
|
|
67
|
+
PrintRequest(w, "GET", null, headers);
|
|
68
|
+
yield return w;
|
|
69
|
+
PrintResponse(w);
|
|
70
|
+
if (!string.IsNullOrEmpty(w.error))
|
|
71
|
+
{
|
|
72
|
+
string data = w.text;
|
|
73
|
+
if (data != null)
|
|
74
|
+
{
|
|
75
|
+
methodForError(GetResponseCode(w), data);
|
|
76
|
+
}
|
|
77
|
+
else
|
|
78
|
+
{
|
|
79
|
+
methodForError(GetResponseCode(w), w.error);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
w.Dispose();
|
|
83
|
+
yield break;
|
|
84
|
+
}
|
|
85
|
+
else
|
|
86
|
+
{
|
|
87
|
+
string data = w.text;
|
|
88
|
+
if (data != null)
|
|
89
|
+
{
|
|
90
|
+
methodForResult(w.text);
|
|
91
|
+
yield break;
|
|
92
|
+
}
|
|
93
|
+
else
|
|
94
|
+
{
|
|
95
|
+
methodForError(GetResponseCode(w), "Empyt response from server : " + url);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ReSharper disable Unity.PerformanceAnalysis
|
|
101
|
+
private IEnumerator Post(string url, Dictionary<string, string> queryParams, Dictionary<string, string> formParams, Action<string> methodForResult, Action<int, string> methodForError)
|
|
102
|
+
{
|
|
103
|
+
string baseUrl;
|
|
104
|
+
Dictionary<string, string> finalQueryParams = queryParams ?? new Dictionary<string, string>();
|
|
105
|
+
NameValueCollection collection = new NameValueCollection();
|
|
106
|
+
ParseUrl(url, out baseUrl, out collection);
|
|
107
|
+
foreach (string key in collection.AllKeys)
|
|
108
|
+
{
|
|
109
|
+
foreach (string value in collection.GetValues(key))
|
|
110
|
+
{
|
|
111
|
+
finalQueryParams.Add(key, value);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
string finalUrl;
|
|
115
|
+
if(finalQueryParams.Count == 0)
|
|
116
|
+
{
|
|
117
|
+
finalUrl = baseUrl;
|
|
118
|
+
} else
|
|
119
|
+
{
|
|
120
|
+
finalUrl = baseUrl + "?" + DictToQueryString(finalQueryParams);
|
|
121
|
+
}
|
|
122
|
+
WWWForm wwwForm = new WWWForm();
|
|
123
|
+
Dictionary<string, string> finalFormParams = formParams ?? new Dictionary<string, string>();
|
|
124
|
+
foreach (KeyValuePair<string, string> kv in finalFormParams)
|
|
125
|
+
{
|
|
126
|
+
// Debug.Log($"kv.key:{kv.Key} value:{kv.Value}");
|
|
127
|
+
wwwForm.AddField(kv.Key, kv.Value);
|
|
128
|
+
; }
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
Dictionary<string, string> headers = new Dictionary<string, string>();
|
|
132
|
+
headers.Add("User-Agent", "TapTapUnitySDK/1.0 " + "UnityPlayer/" + Application.unityVersion);
|
|
133
|
+
WWW w = new WWW(finalUrl, wwwForm.data, headers);
|
|
134
|
+
PrintRequest(w, "POST", wwwForm, headers);
|
|
135
|
+
yield return w;
|
|
136
|
+
PrintResponse(w);
|
|
137
|
+
if (!string.IsNullOrEmpty(w.error))
|
|
138
|
+
{
|
|
139
|
+
string data = w.text;
|
|
140
|
+
if (data != null)
|
|
141
|
+
{
|
|
142
|
+
methodForError(GetResponseCode(w), data);
|
|
143
|
+
}
|
|
144
|
+
else
|
|
145
|
+
{
|
|
146
|
+
methodForError(GetResponseCode(w), w.error);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
w.Dispose();
|
|
150
|
+
yield break;
|
|
151
|
+
}
|
|
152
|
+
else
|
|
153
|
+
{
|
|
154
|
+
string data = w.text;
|
|
155
|
+
if (data != null)
|
|
156
|
+
{
|
|
157
|
+
methodForResult(w.text);
|
|
158
|
+
yield break;
|
|
159
|
+
}
|
|
160
|
+
else
|
|
161
|
+
{
|
|
162
|
+
methodForError(GetResponseCode(w), "Empyt response from server : " + url);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
public static void PrintRequest(WWW request, string method, WWWForm wwwFrom, Dictionary<string, string> headers) {
|
|
167
|
+
if (TapLogger.LogDelegate == null) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (request == null) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
StringBuilder sb = new StringBuilder();
|
|
174
|
+
sb.AppendLine("=== HTTP Request Start ===");
|
|
175
|
+
sb.AppendLine($"URL: {request.url}");
|
|
176
|
+
sb.AppendLine($"Method: {method}");
|
|
177
|
+
|
|
178
|
+
sb.AppendLine($"Headers: \t");
|
|
179
|
+
if (wwwFrom?.headers != null)
|
|
180
|
+
{
|
|
181
|
+
foreach (var header in wwwFrom.headers) {
|
|
182
|
+
sb.AppendLine($"{header.Key}: {header.Value}");
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (headers != null)
|
|
187
|
+
{
|
|
188
|
+
foreach (var header in headers) {
|
|
189
|
+
sb.AppendLine($"{header.Key}: {header.Value}");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
sb.AppendLine("=== HTTP Request End ===");
|
|
193
|
+
TapLogger.Debug(sb.ToString());
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private static void PrintResponse(WWW response) {
|
|
197
|
+
if (TapLogger.LogDelegate == null) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
StringBuilder sb = new StringBuilder();
|
|
201
|
+
sb.AppendLine("=== HTTP Response Start ===");
|
|
202
|
+
sb.AppendLine($"URL: {response.url}");
|
|
203
|
+
sb.AppendLine($"Status Code: {GetResponseCode(response)}");
|
|
204
|
+
sb.AppendLine($"error: {response.error}");
|
|
205
|
+
if (!string.IsNullOrEmpty(response.text)) {
|
|
206
|
+
sb.AppendLine($"Content: {response.text}");
|
|
207
|
+
}
|
|
208
|
+
sb.AppendLine("=== HTTP Response End ===");
|
|
209
|
+
TapLogger.Debug(sb.ToString());
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public static int GetResponseCode(WWW request)
|
|
213
|
+
{
|
|
214
|
+
int ret = 0;
|
|
215
|
+
if (request.responseHeaders == null)
|
|
216
|
+
{
|
|
217
|
+
Debug.LogError("no response headers.");
|
|
218
|
+
}
|
|
219
|
+
else
|
|
220
|
+
{
|
|
221
|
+
if (!request.responseHeaders.ContainsKey("STATUS"))
|
|
222
|
+
{
|
|
223
|
+
Debug.LogError("response headers has no STATUS.");
|
|
224
|
+
}
|
|
225
|
+
else
|
|
226
|
+
{
|
|
227
|
+
ret = ParseResponseCode(request.responseHeaders["STATUS"]);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return ret;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public static int ParseResponseCode(string statusLine)
|
|
235
|
+
{
|
|
236
|
+
int ret = 0;
|
|
237
|
+
|
|
238
|
+
string[] components = statusLine.Split(' ');
|
|
239
|
+
if (components.Length < 3)
|
|
240
|
+
{
|
|
241
|
+
Debug.LogError("invalid response status: " + statusLine);
|
|
242
|
+
}
|
|
243
|
+
else
|
|
244
|
+
{
|
|
245
|
+
if (!int.TryParse(components[1], out ret))
|
|
246
|
+
{
|
|
247
|
+
Debug.LogError("invalid response code: " + components[1]);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return ret;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
public static string DictToQueryString(IDictionary<string, string> dict)
|
|
255
|
+
{
|
|
256
|
+
List<string> list = new List<string>();
|
|
257
|
+
foreach (var item in dict)
|
|
258
|
+
{
|
|
259
|
+
list.Add(item.Key + "=" + item.Value);
|
|
260
|
+
}
|
|
261
|
+
return string.Join("&", list.ToArray());
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public static void ParseUrl(string url, out string baseUrl, out NameValueCollection nvc)
|
|
265
|
+
{
|
|
266
|
+
if (url == null)
|
|
267
|
+
throw new ArgumentNullException("url");
|
|
268
|
+
nvc = new NameValueCollection();
|
|
269
|
+
baseUrl = "";
|
|
270
|
+
if (url == "")
|
|
271
|
+
return;
|
|
272
|
+
int questionMarkIndex = url.IndexOf('?');
|
|
273
|
+
if (questionMarkIndex == -1)
|
|
274
|
+
{
|
|
275
|
+
baseUrl = url;
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
baseUrl = url.Substring(0, questionMarkIndex);
|
|
279
|
+
if (questionMarkIndex == url.Length - 1)
|
|
280
|
+
return;
|
|
281
|
+
string ps = url.Substring(questionMarkIndex + 1);
|
|
282
|
+
Regex re = new Regex(@"(^|&)?(\w+)=([^&]+)(&|$)?", RegexOptions.None);
|
|
283
|
+
MatchCollection mc = re.Matches(ps);
|
|
284
|
+
foreach (Match m in mc)
|
|
285
|
+
{
|
|
286
|
+
nvc.Add(m.Result("$2").ToLower(), m.Result("$3"));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
}
|
|
291
|
+
}
|