TH1/Unity/Assets/Scripts/Hotfix/Server/Demo/Router/HttpGetRouterHandler.cs
2025-07-17 18:26:28 +08:00

27 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
namespace ET.Server
{
[HttpHandler(SceneType.RouterManager, "/get_router")]
public class HttpGetRouterHandler : IHttpHandler
{
public async ETTask Handle(Scene scene, HttpListenerContext context)
{
HttpGetRouterResponse response = HttpGetRouterResponse.Create();
foreach (StartSceneConfig startSceneConfig in StartSceneConfigCategory.Instance.Realms)
{
// 这里是要用InnerIP因为云服务器上realm绑定不了OuterIP的,所以realm的内网外网的socket都是监听内网地址
response.Realms.Add(startSceneConfig.InnerIPPort.ToString());
}
foreach (StartSceneConfig startSceneConfig in StartSceneConfigCategory.Instance.Routers)
{
response.Routers.Add($"{startSceneConfig.StartProcessConfig.OuterIP}:{startSceneConfig.Port}");
}
HttpHelper.Response(context, response);
await ETTask.CompletedTask;
}
}
}