yuanshen/Yuanshen.SDK/Handlers/RegionHandler.cs
wisedev 61cc2055cf First working version of the server
KCP gameserver with packet dispatch, scene streaming, combat, gacha and the
shop, plus a small HTTP server for the login flow and the wish history page.

Game data under assets is pulled out of the client instead of being typed by
hand. The excel tables come from the packed bin container and the spawn points
from the compiled scene scripts.
2026-09-04 02:06:53 +03:00

55 lines
1.8 KiB
C#

using Google.Protobuf;
using Yuanshen.Protocol;
namespace Yuanshen.SDK.Handlers;
public static class RegionHandler
{
private const string GATESERVER_IP = "127.0.0.1";
private const int GATESERVER_PORT = 22102;
private const string CLIENT_CUSTOM_CONFIG = "{\"sdkenv\":\"2\",\"checkdevice\":\"false\",\"loadPatch\":\"false\",\"showexception\":\"false\",\"regionConfig\":\"pm|fk|add\",\"downloadMode\":\"0\"}";
private static readonly string s_regionList = BuildRegionList();
private static readonly string s_curRegion = BuildCurRegion();
public static IResult OnQueryRegionList() => TypedResults.Text(s_regionList, "text/plain");
public static IResult OnQueryCurRegion() => TypedResults.Text(s_curRegion, "text/plain");
private static string BuildRegionList()
{
QueryRegionListHttpRsp rsp = new()
{
Retcode = 0,
EnableLoginPc = true,
ClientCustomConfigEncrypted = ByteString.CopyFromUtf8(CLIENT_CUSTOM_CONFIG),
Servers =
{
new RegionSimpleInfo
{
Name = "os_yuanshen",
Title = "Yuanshen",
Type = "DEV_PUBLIC",
DispatchUrl = $"http://{GATESERVER_IP}:8899/query_cur_region"
}
}
};
return Convert.ToBase64String(rsp.ToByteArray());
}
private static string BuildCurRegion()
{
QueryCurrRegionHttpRsp rsp = new()
{
Retcode = 0,
RegionInfo = new RegionInfo
{
Ip = GATESERVER_IP,
Port = GATESERVER_PORT
},
RegionCustomConfigEncrypted = ByteString.CopyFromUtf8(CLIENT_CUSTOM_CONFIG)
};
return Convert.ToBase64String(rsp.ToByteArray());
}
}