diff --git a/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetwork.Standard2.dll b/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetwork.Standard2.dll new file mode 100644 index 0000000..3802b84 Binary files /dev/null and b/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetwork.Standard2.dll differ diff --git a/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetwork.Standard2.dll.meta b/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetwork.Standard2.dll.meta new file mode 100644 index 0000000..0c56f22 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetwork.Standard2.dll.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 898ba71ded907534ba7eaada7855cadc \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll b/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll deleted file mode 100644 index c3c4a90..0000000 Binary files a/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll and /dev/null differ diff --git a/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll.meta b/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll.meta deleted file mode 100644 index fa5284c..0000000 --- a/AxibugEmuOnline.Client/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: 324deac494a24a7499801349c7908062 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttp.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttp.cs index 7b5d29d..844cd2b 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttp.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttp.cs @@ -11,8 +11,65 @@ using System.Security.Cryptography.X509Certificates; using System.Text; using System.Text.RegularExpressions; using System.Threading; -using System.Threading.Tasks; +public static class PSVThread +{ + static AutoResetEvent autoEvent = new AutoResetEvent(false); + static Queue qActs = new Queue(); + static Queue qWork = new Queue(); + + public static void DoTask(Action act) + { +#if UNITY_PSP2 + AddSingleTask(act); +#else + ThreadPool.QueueUserWorkItem(new WaitCallback((state) => act.Invoke())); +#endif + } + +#if UNITY_PSP2 + static Thread psvThread = new Thread(Loop); + static bool bSingleInit = false; + static void SingleInit() + { + if (bSingleInit) return; + psvThread.Start(); + bSingleInit = true; + } + static void AddSingleTask(Action act) + { + SingleInit(); + lock (qActs) + { + qActs.Enqueue(act); + } + autoEvent.Set(); + } + + static void Loop() + { + while (autoEvent.WaitOne()) + { + lock (qActs) + { + while (qActs.Count > 0) { qWork.Enqueue(qActs.Dequeue()); } + } + while (qWork.Count > 0) + { + Action act = qWork.Dequeue(); + try + { + act.Invoke(); + } + catch (Exception ex) + { + UnityEngine.Debug.Log(ex.ToString()); + } + } + } + } +#endif +} public static class AxiHttp { @@ -127,14 +184,15 @@ public static class AxiHttp AxiRespInfo respInfo = new AxiRespInfo(); respInfo.downloadMode = AxiDownLoadMode.NotDownLoad; WaitAxiRequest respAsync = new WaitAxiRequest(respInfo); - Task task = new Task(() => SendAxiRequest(url, ref respInfo)); - task.Start(); + //Task task = new Task(() => SendAxiRequest(url, ref respInfo)); + //task.Start() + PSVThread.DoTask(() => SendAxiRequest(url, ref respInfo)); return respAsync; } public static AxiRespInfo AxiDownload(string url) { - AxiRespInfo respInfo = new AxiRespInfo(); + AxiRespInfo respInfo = new AxiRespInfo(); respInfo.downloadMode = AxiDownLoadMode.DownLoadBytes; SendAxiRequest(url, ref respInfo); return respInfo; @@ -142,19 +200,20 @@ public static class AxiHttp public static AxiRespInfo AxiDownloadAsync(string url) { - AxiRespInfo respInfo = new AxiRespInfo(); + AxiRespInfo respInfo = new AxiRespInfo(); respInfo.downloadMode = AxiDownLoadMode.DownLoadBytes; - Task task = new Task(() => SendAxiRequest(url, ref respInfo)); - task.Start(); + //Task task = new Task(() => SendAxiRequest(url, ref respInfo)); + //task.Start(); + PSVThread.DoTask(() => SendAxiRequest(url, ref respInfo)); return respInfo; } - static void SendAxiRequest(string url, ref AxiRespInfo respinfo,int timeout = 1000 * 1000, string encoding = "UTF-8") + static void SendAxiRequest(string url, ref AxiRespInfo respinfo, int timeout = 1000 * 1000, string encoding = "UTF-8") { if (url.ToLower().StartsWith("https://")) - SendAxiRequestHttps(url, ref respinfo,timeout, encoding);// SendAxiRequestHttps(url, ref respinfo, timeout, encoding); + SendAxiRequestHttps(url, ref respinfo, timeout, encoding);// SendAxiRequestHttps(url, ref respinfo, timeout, encoding); else - SendAxiRequestHttp(url, ref respinfo,timeout, encoding); + SendAxiRequestHttp(url, ref respinfo, timeout, encoding); } static void SendAxiRequestHttp(string url, ref AxiRespInfo respinfo, int timeout, string encoding) @@ -735,6 +794,9 @@ public static class AxiHttp //} respinfo.isDone = true; } + + if (client != null) + client.Dispose(); } @@ -1023,7 +1085,7 @@ public static class AxiHttp { try { - Log($"convertToIntBy16 str- {str} lenght->{str.Length}"); + //Log($"convertToIntBy16 str- {str} lenght->{str.Length}"); if (str.Length == 0) return 0; return Convert.ToInt32(str, 16); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttpProxy.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttpProxy.cs index ec6172e..16d81d2 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttpProxy.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttpProxy.cs @@ -1,4 +1,3 @@ -using System.Collections; using UnityEngine; using static AxiHttp; @@ -46,6 +45,8 @@ public static class AxiHttpProxy public static void ShowAxiHttpDebugInfo(AxiRespInfo resp) { + +#if UNITY_EDITOR Debug.Log($""); Debug.Log($"==== request ===="); Debug.Log($"url =>{resp.url}"); @@ -70,6 +71,23 @@ public static class AxiHttpProxy Debug.Log($"respInfo.fileName =>{resp.fileName}"); Debug.Log($"respInfo.NeedloadedLenght =>{resp.NeedloadedLenght}"); Debug.Log($"respInfo.loadedLenght =>{resp.loadedLenght}"); +#else + Debug.Log($"==== request url => { resp.url}"); + Debug.Log($"code =>{resp.code}"); + Debug.Log($"respInfo.bTimeOut =>{resp.bTimeOut}"); + Debug.Log($"==== response ===="); + if (resp.downloadMode == AxiDownLoadMode.NotDownLoad) + { + Debug.Log($"body_text =>{resp.body}"); + Debug.Log($"body_text.Length =>{resp.body.Length}"); + } + else + { + Debug.Log($"==== download ===="); + Debug.Log($"respInfo.loadedLenght =>{resp.loadedLenght}"); + } +#endif + //if (resp.downloadMode == AxiDownLoadMode.DownLoadBytes) //{ // if (resp.bTimeOut) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/CacheManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/CacheManager.cs index c2ce0b6..7d5e3b1 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/CacheManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/CacheManager.cs @@ -36,7 +36,7 @@ namespace AxibugEmuOnline.Client } AxiHttpProxy.ShowAxiHttpDebugInfo(request.downloadHandler); - if (request.downloadHandler.Err != null) + if (request.downloadHandler.Err == null) { Directory.CreateDirectory(path); File.WriteAllBytes($"{path}/{url.GetHashCode()}", request.downloadHandler.data); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomFile.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomFile.cs index d932481..d39c576 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomFile.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomFile.cs @@ -136,14 +136,10 @@ namespace AxibugEmuOnline.Client var request = downloadRequest; downloadRequest = null; - if (request.downloadHandler.Err != null) - { - callback(null); - } + if (request.downloadHandler.Err == null) + callback(request.downloadHandler.data); else - { - callback(request.downloadHandler.data); - } + callback(null); //downloadRequest = UnityWebRequest.Get($"{App.httpAPI.WebHost}/{webData.url}"); //yield return downloadRequest.SendWebRequest(); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetworkHelper.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetworkHelper.cs index c38657d..e6c0c53 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetworkHelper.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetworkHelper.cs @@ -1,6 +1,6 @@ using AxibugEmuOnline.Client.ClientCore; using AxibugProtobuf; -using HaoYueNet.ClientNetworkNet.Standard2; +using HaoYueNet.ClientNetwork; using System; using System.Net.Sockets; using System.Threading;