修改HttpServer
This commit is contained in:
@ -13,7 +13,7 @@ MonoBehaviour:
|
||||
m_Name: Android Settings
|
||||
m_EditorClassIdentifier:
|
||||
m_LoaderManagerInstance: {fileID: -4694385543675108017}
|
||||
m_InitManagerOnStart: 0
|
||||
m_InitManagerOnStart: 1
|
||||
--- !u!114 &-4694385543675108017
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -65803,6 +65803,52 @@ MonoBehaviour:
|
||||
m_Flags: 0
|
||||
m_Reference: {fileID: 0}
|
||||
m_ButtonPressPoint: 0.5
|
||||
--- !u!1 &641991421
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 641991423}
|
||||
- component: {fileID: 641991422}
|
||||
m_Layer: 0
|
||||
m_Name: HttpServer
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &641991422
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 641991421}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 61fbd59abecedaa41b1a41080bb5716b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
gameId: 0
|
||||
vistAllTime: 900
|
||||
--- !u!4 &641991423
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 641991421}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -2.9327452, y: -2.3641474, z: 1.7679554}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &650522291
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -236151,3 +236197,4 @@ SceneRoots:
|
||||
- {fileID: 2076119386}
|
||||
- {fileID: 471303171}
|
||||
- {fileID: 927674475}
|
||||
- {fileID: 641991423}
|
||||
|
||||
@ -70,14 +70,13 @@ public class HttpServer : MonoBehaviour
|
||||
private volatile bool needLoadMainScene = false;
|
||||
void Awake()
|
||||
{
|
||||
Ins = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
|
||||
Task.Run(StartServer);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartServer();
|
||||
|
||||
}
|
||||
|
||||
#region HTTP Server
|
||||
@ -87,12 +86,11 @@ public class HttpServer : MonoBehaviour
|
||||
try
|
||||
{
|
||||
listener = new HttpListener();
|
||||
listener.Prefixes.Add(SERVER_URL);
|
||||
listener.Prefixes.Add($"http://{GetLocalIP()}:12345/");
|
||||
listener.Start();
|
||||
Debug.Log("http开始启动:");
|
||||
|
||||
isRunning = true;
|
||||
ListenLoop();
|
||||
serverThread.Start();
|
||||
|
||||
Debug.Log($"✅ HTTP Server 启动成功:{SERVER_URL}");
|
||||
}
|
||||
@ -100,7 +98,18 @@ public class HttpServer : MonoBehaviour
|
||||
{
|
||||
Debug.LogError("❌ HTTP Server 启动失败:" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
@ -146,7 +146,7 @@ EditorBuildSettings:
|
||||
- enabled: 0
|
||||
path: Assets/_Valheim/Scenes/Guangdong_Guangzhou_Yanghaiyan_Lihu.unity
|
||||
guid: d466148b4c224d74380804d8673bf7f6
|
||||
- enabled: 1
|
||||
- enabled: 0
|
||||
path: Assets/_Valheim/Scenes/Nanjing_Pukou_Longhutianjie.unity
|
||||
guid: 4aee1d85169380f48a01ec5652adfb64
|
||||
- enabled: 0
|
||||
@ -281,7 +281,7 @@ EditorBuildSettings:
|
||||
- enabled: 0
|
||||
path: Assets/_Valheim/Scenes/Liaoning_Huludao_Jianchang_XinglongDajiating.unity
|
||||
guid: bef16f778ad7c2044bf4d16e9f8054fc
|
||||
- enabled: 0
|
||||
- enabled: 1
|
||||
path: Assets/_Valheim/Scenes/Shanxi_Yulin_Shenmu_Liuta_Yuyuecheng.unity
|
||||
guid: a1509bb98f909d244b5ebd941b1f73d6
|
||||
- enabled: 0
|
||||
|
||||
@ -165,7 +165,7 @@ PlayerSettings:
|
||||
androidSupportedAspectRatio: 1
|
||||
androidMaxAspectRatio: 2.1
|
||||
applicationIdentifier:
|
||||
Android: com.pineappletech.valheim.nanjingpukoulonghutianjie
|
||||
Android: com.pineappletech.valheim.shanxiyulinshenmuliutayuyuecheng
|
||||
buildNumber:
|
||||
Standalone: 0
|
||||
VisionOS: 0
|
||||
|
||||
Reference in New Issue
Block a user