修改HttpServer,进入速度加快

This commit is contained in:
2026-02-11 15:49:23 +08:00
parent a53dc494a8
commit 6e73118bd9
3 changed files with 20 additions and 11 deletions

View File

@ -6,6 +6,7 @@ using System.Threading;
using System.Collections.Concurrent;
using UnityEngine;
using Valheim;
using System.Threading.Tasks;
[Serializable]
public class IntentMessage
@ -42,12 +43,13 @@ public class HttpServer : MonoBehaviour
void Awake()
{
DontDestroyOnLoad(gameObject);
Task.Run(StartServer);
}
void Start()
{
StartServer();
}
#region HTTP Server
@ -57,15 +59,11 @@ public class HttpServer : MonoBehaviour
try
{
listener = new HttpListener();
listener.Prefixes.Add(SERVER_URL);
listener.Prefixes.Add($"http://{GetLocalIP()}:12345/");
listener.Start();
isRunning = true;
serverThread = new Thread(ListenLoop)
{
IsBackground = true
};
serverThread.Start();
ListenLoop();
Debug.Log($"✅ HTTP Server 启动成功:{SERVER_URL}");
}
@ -75,6 +73,17 @@ public class HttpServer : MonoBehaviour
}
}
private string GetLocalIP()
{
var host = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
return ip.ToString();
}
return "127.0.0.1";
}
private void ListenLoop()
{
while (isRunning && listener.IsListening)

View File

@ -227,7 +227,7 @@ EditorBuildSettings:
- enabled: 0
path: Assets/_Zombie/Scenes/Liaoning_Panjin_Xinglongtai_Shuiyoucheng.unity
guid: 796a76765ad2af047b0a8bc7fd6cfbb9
- enabled: 0
- enabled: 1
path: Assets/_Zombie/Scenes/Shanxi_Yulin_Shenmu_Liuta_Yuyuecheng.unity
guid: 79ef7bd94ba23834d900bf99028ce951
- enabled: 0
@ -245,7 +245,7 @@ EditorBuildSettings:
- enabled: 0
path: Assets/_Zombie/Scenes/Ningxia_Yinchuan_Xingqing_XinhuaBaihuo_Shiwai.unity
guid: 8d49e8d3356159249b0895ad9486ede4
- enabled: 1
- enabled: 0
path: Assets/_Zombie/Scenes/Ningxia_Wuzhong_Litong_YiwuShangmaocheng.unity
guid: fbfd3e21f4f625f439981c19a7d8b822
m_configObjects:

View File

@ -163,7 +163,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
applicationIdentifier:
Android: com.pineappletech.zombie.ningxiawuzhonglitongyiwushangmaocheng
Android: com.pineappletech.zombie.shanxiyulinshenmuliutayuyuecheng
Standalone: com.DefaultCompany.com.unity.template.ar
buildNumber:
Standalone: 0