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 = Retcode.RET_SUCC, 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 = Retcode.RET_SUCC, RegionInfo = new RegionInfo { Ip = GATESERVER_IP, Port = GATESERVER_PORT }, RegionCustomConfigEncrypted = ByteString.CopyFromUtf8(CLIENT_CUSTOM_CONFIG) }; return Convert.ToBase64String(rsp.ToByteArray()); } }