备份CatanBuilding瘦身独立工程

This commit is contained in:
JSD\13999
2026-05-26 16:15:54 +08:00
commit 2d0e6a61b7
12001 changed files with 2431925 additions and 0 deletions

View File

@@ -0,0 +1,155 @@
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Collections.Generic;
using ThinkingSDK.PC.Constant;
using ThinkingSDK.PC.Utils;
using System.IO;
using UnityEngine.Networking;
using System.Collections;
using ThinkingSDK.PC.Config;
namespace ThinkingSDK.PC.Request
{
/*
* Enumerate the form of data reported by post, and the enumeration value represents json and form forms
*/
enum POST_TYPE { JSON, FORM };
public abstract class ThinkingSDKBaseRequest
{
private string mAppid;
private string mURL;
private string mData;
public ThinkingSDKBaseRequest(string appId, string url, string data)
{
mAppid = appId;
mURL = url;
mData = data;
}
public ThinkingSDKBaseRequest(string appId, string url)
{
mAppid = appId;
mURL = url;
}
public void SetData(string data)
{
this.mData = data;
}
public string APPID() {
return mAppid;
}
public string URL()
{
return mURL;
}
public string Data()
{
return mData;
}
/**
* initialization interface
*/
public static void GetConfig(string url,ResponseHandle responseHandle)
{
if (!ThinkingSDKUtil.IsValiadURL(url))
{
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Invalid Url:\n" + url);
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
var responseResult = new StreamReader(response.GetResponseStream()).ReadToEnd();
if (responseResult != null)
{
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Request URL:\n"+url);
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Response:\n"+responseResult);
}
}
public bool MyRemoteCertificateValidationCallback(System.Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
bool isOk = true;
// If there are errors in the certificate chain,
// look at each error to determine the cause.
if (sslPolicyErrors != SslPolicyErrors.None) {
for (int i=0; i<chain.ChainStatus.Length; i++) {
if (chain.ChainStatus[i].Status == X509ChainStatusFlags.RevocationStatusUnknown) {
continue;
}
chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain;
chain.ChainPolicy.RevocationMode = X509RevocationMode.Online;
chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan (0, 1, 0);
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;
bool chainIsValid = chain.Build ((X509Certificate2)certificate);
if (!chainIsValid) {
isOk = false;
break;
}
}
}
return isOk;
}
abstract public IEnumerator SendData_2(ResponseHandle responseHandle, string data, int eventCount);
public static IEnumerator GetWithFORM_2(string url, string appId, Dictionary<string, object> param, ResponseHandle responseHandle)
{
string uri = url + "?appid=" + appId;
if (param != null)
{
uri = uri + "&data=" + ThinkingSDKJSON.Serialize(param);
}
using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
{
webRequest.timeout = 30;
webRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Request URL: \n" + uri);
// Request and wait for the desired page.
yield return webRequest.SendWebRequest();
Dictionary<string,object> resultDict = null;
#if UNITY_2020_1_OR_NEWER
switch (webRequest.result)
{
case UnityWebRequest.Result.ConnectionError:
case UnityWebRequest.Result.DataProcessingError:
case UnityWebRequest.Result.ProtocolError:
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Error response: \n" + webRequest.error);
break;
case UnityWebRequest.Result.Success:
string resultText = webRequest.downloadHandler.text;
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Response: \n" + resultText);
if (!string.IsNullOrEmpty(resultText))
{
resultDict = ThinkingSDKJSON.Deserialize(resultText);
}
break;
}
#else
if (webRequest.isHttpError || webRequest.isNetworkError)
{
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Error response: \n" + webRequest.error);
}
else
{
string resultText = webRequest.downloadHandler.text;
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Response: \n" + resultText);
if (!string.IsNullOrEmpty(resultText))
{
resultDict = ThinkingSDKJSON.Deserialize(resultText);
}
}
#endif
if (responseHandle != null)
{
responseHandle(resultDict);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3b31966af44764a508681ee9d6e24f7a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,95 @@
using System.Collections.Generic;
using ThinkingSDK.PC.Config;
using ThinkingSDK.PC.Constant;
using ThinkingSDK.PC.Utils;
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
namespace ThinkingSDK.PC.Request
{
public class ThinkingSDKDebugRequest:ThinkingSDKBaseRequest
{
private int mDryRun = 0;
private string mDeviceID = ThinkingSDKDeviceInfo.DeviceID();
public void SetDryRun(int dryRun)
{
mDryRun = dryRun;
}
public ThinkingSDKDebugRequest(string appId, string url, string data):base(appId,url,data)
{
}
public ThinkingSDKDebugRequest(string appId, string url) : base(appId, url)
{
}
public override IEnumerator SendData_2(ResponseHandle responseHandle, string data, int eventCount)
{
this.SetData(data);
string uri = this.URL();
//string content = ThinkingSDKJSON.Serialize(this.Data()[0]);
string content = data.Substring(1,data.Length-2);
WWWForm form = new WWWForm();
form.AddField("appid", this.APPID());
form.AddField("source", "client");
form.AddField("dryRun", mDryRun);
form.AddField("deviceId", mDeviceID);
form.AddField("data", content);
using (UnityWebRequest webRequest = UnityWebRequest.Post(uri, form))
{
webRequest.timeout = 30;
webRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Request:\n " + content + "\n URL = " + uri);
// Request and wait for the desired page.
yield return webRequest.SendWebRequest();
Dictionary<string,object> resultDict = null;
#if UNITY_2020_1_OR_NEWER
switch (webRequest.result)
{
case UnityWebRequest.Result.ConnectionError:
case UnityWebRequest.Result.DataProcessingError:
case UnityWebRequest.Result.ProtocolError:
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response Error:\n " + webRequest.error);
break;
case UnityWebRequest.Result.Success:
string resultText = webRequest.downloadHandler.text;
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response:\n " + resultText);
if (!string.IsNullOrEmpty(resultText))
{
resultDict = ThinkingSDKJSON.Deserialize(resultText);
}
break;
}
#else
if (webRequest.isHttpError || webRequest.isNetworkError)
{
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response Error:\n " + webRequest.error);
}
else
{
string resultText = webRequest.downloadHandler.text;
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response:\n " + resultText);
if (!string.IsNullOrEmpty(resultText))
{
resultDict = ThinkingSDKJSON.Deserialize(resultText);
}
}
#endif
if (responseHandle != null)
{
if (resultDict != null)
{
resultDict.Add("flush_count", eventCount);
}
responseHandle(resultDict);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7849691904f3c426e81a91572a027863
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Text;
using ThinkingSDK.PC.Constant;
using ThinkingSDK.PC.Utils;
using UnityEngine.Networking;
using System.Collections;
using ThinkingSDK.PC.Config;
namespace ThinkingSDK.PC.Request
{
public class ThinkingSDKNormalRequest:ThinkingSDKBaseRequest
{
public ThinkingSDKNormalRequest(string appId, string url, string data) :base(appId, url, data)
{
}
public ThinkingSDKNormalRequest(string appId, string url) : base(appId, url)
{
}
public override IEnumerator SendData_2(ResponseHandle responseHandle, string data, int eventCount)
{
this.SetData(data);
string uri = this.URL();
var flush_time = ThinkingSDKUtil.GetTimeStamp();
string content = "{\"#app_id\":\"" + this.APPID() + "\",\"data\":" + data + ",\"#flush_time\":" + flush_time + "}";
string encodeContent = Encode(content);
byte[] contentCompressed = Encoding.UTF8.GetBytes(encodeContent);
using (UnityWebRequest webRequest = new UnityWebRequest(uri, "POST"))
{
webRequest.timeout = 30;
webRequest.SetRequestHeader("Content-Type", "text/plain");
webRequest.SetRequestHeader("appid", this.APPID());
webRequest.SetRequestHeader("TA-Integration-Type", "PC");
webRequest.SetRequestHeader("TA-Integration-Version", ThinkingSDKPublicConfig.Version());
webRequest.SetRequestHeader("TA-Integration-Count", "1");
webRequest.SetRequestHeader("TA-Integration-Extra", "PC");
webRequest.uploadHandler = (UploadHandler)new UploadHandlerRaw(contentCompressed);
webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Request:\n " + content + "\n URL = " + uri);
// Request and wait for the desired page.
yield return webRequest.SendWebRequest();
Dictionary<string, object> resultDict = null;
#if UNITY_2020_1_OR_NEWER
switch (webRequest.result)
{
case UnityWebRequest.Result.ConnectionError:
case UnityWebRequest.Result.DataProcessingError:
case UnityWebRequest.Result.ProtocolError:
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response Error:\n " + webRequest.error);
break;
case UnityWebRequest.Result.Success:
string resultText = webRequest.downloadHandler.text;
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response:\n " + resultText);
if (!string.IsNullOrEmpty(resultText))
{
resultDict = ThinkingSDKJSON.Deserialize(resultText);
}
break;
}
#else
if (webRequest.isHttpError || webRequest.isNetworkError)
{
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response Error:\n " + webRequest.error);
}
else
{
string resultText = webRequest.downloadHandler.text;
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response:\n " + resultText);
if (!string.IsNullOrEmpty(resultText))
{
resultDict = ThinkingSDKJSON.Deserialize(resultText);
}
}
#endif
if (responseHandle != null)
{
if (resultDict != null)
{
resultDict.Add("flush_count", eventCount);
}
responseHandle(resultDict);
}
}
}
private static string Encode(string inputStr)
{
byte[] inputBytes = Encoding.UTF8.GetBytes(inputStr);
using (var outputStream = new MemoryStream())
{
using (var gzipStream = new GZipStream(outputStream, CompressionMode.Compress))
gzipStream.Write(inputBytes, 0, inputBytes.Length);
byte[] output = outputStream.ToArray();
return Convert.ToBase64String(output);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 992a71ad5ae554eb98a712f6a65b3a7f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: