From 1ab047b5fdd933c38ba0519ec2e83a44512ea8d7 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 26 三月 2026 17:46:11 +0800
Subject: [PATCH] webgl代码合并 1
---
Main/System/Login/ServerListCenter.cs | 47 +++++++++++++++++++++++++++++++++++++----------
1 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/Main/System/Login/ServerListCenter.cs b/Main/System/Login/ServerListCenter.cs
index e5b7eb0..57fff87 100644
--- a/Main/System/Login/ServerListCenter.cs
+++ b/Main/System/Login/ServerListCenter.cs
@@ -3,12 +3,13 @@
using UnityEngine;
using LitJson;
using System;
+using Cysharp.Threading.Tasks;
public class ServerListCenter : Singleton<ServerListCenter>
{
public static readonly string[] JUMP_URL = new string[]
{
- "http://xssgcenter.secondworld.net.cn:11000/center/server_list.php/?",
+ "http://gamecenter.secondworld.net.cn:11000/center/server_list.php/?",
"http://106.55.151.92:11000/center/server_list_new.php/?"
};
@@ -195,16 +196,23 @@
}
- public void RequestJumpUrl()
+ public async UniTask RequestJumpUrl()
{
- if (VersionUtility.Instance.InIosAuditTime())
+ if (await VersionUtility.Instance.InIosAuditTime())
{
return;
}
- var url = StringUtility.Concat(JUMP_URL[jumpUrlIndex % JUMP_URL.Length], "game=xssg&flag=", VersionConfig.Get().appId, "_", VersionConfig.Get().branch.ToString(), "_", VersionConfig.Get().version);
+ if (VersionConfig.config == null)
+ {
+ throw new System.Exception("VersionConfig is null when RequestJumpUrl, check VersionConfig.GetAsync for more details");
+ }
+
+ var url = StringUtility.Concat(JUMP_URL[jumpUrlIndex % JUMP_URL.Length], "game=xssg&flag=", VersionConfig.config.appId, "_", VersionConfig.config.branch.ToString(), "_", VersionConfig.config.version);
jumpUrlIndex++;
serverUrl = url;
+ // 鍔犳椂闂存埑闃叉娴忚鍣�/CDN缂撳瓨
+ url = StringUtility.Concat(url, "&_t=", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString());
Debug.Log("http鍦板潃:serverlist " + url);
HttpRequest.Instance.RequestHttpGet(url, HttpRequest.defaultHttpContentType, 1, OnRequestJumpUrl);
}
@@ -213,17 +221,21 @@
{
if (_ok)
{
+ // 鍘婚櫎鍝嶅簲寮�澶村彲鑳藉瓨鍦ㄧ殑 UTF-8 BOM锛圽uFEFF锛夛紝鍚﹀垯 WebGL 涓嬩細鎷兼垚 localhost:8080/%EF%BB%BF... 瀵艰嚧 404
+ _result = _result.TrimStart('\uFEFF');
+
var serverUrls = _result.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);
SERVERLIST_URL_COMMON = serverUrls[0];
SERVERLIST_URL_PLAYER = serverUrls[1];
-
+ Debug.LogError("SERVERLIST_URL_COMMON is " + SERVERLIST_URL_COMMON);
+ Debug.LogError("SERVERLIST_URL_PLAYER is " + SERVERLIST_URL_PLAYER);
RequestServerList();
}
else
{
Debug.Log("http 鏁版嵁閫氳: ServerlistCenter:" + serverUrl + " result:" + _result);
//BuglyAgent.ReportException(new System.Exception(), "http 鏁版嵁閫氳: ServerlistCenter:" + serverUrl + " result:" + _result);
- Clock.AlarmAt(DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond), RequestJumpUrl);
+ Clock.AlarmAt(DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond), () => RequestJumpUrl().Forget());
}
}
@@ -233,7 +245,12 @@
serverListPlayerPartGot = false;
RequestServerCommonList();
- if (VersionConfig.Get().versionAuthority == VersionAuthority.InterTest)
+ if (VersionConfig.config == null)
+ {
+ throw new System.Exception("VersionConfig is null when RequestServerList, check VersionConfig.GetAsync for more details");
+ }
+
+ if (VersionConfig.config.versionAuthority == VersionAuthority.InterTest)
{
var localSaveAccountName = LocalSave.GetString(LoginManager.USER_ACCOUNT);
RequestServerListPlayer(localSaveAccountName);
@@ -242,18 +259,25 @@
public void RequestServerCommonList()
{
- HttpRequest.Instance.RequestHttpGet(SERVERLIST_URL_COMMON, HttpRequest.defaultHttpContentType, 1, OnGetServerList);
+ // 鍔犳椂闂存埑闃叉娴忚鍣�/CDN缂撳瓨
+ var url = SERVERLIST_URL_COMMON;
+ var separator = url.Contains("?") ? "&" : "?";
+ url = StringUtility.Concat(url, separator, "_t=", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString());
+ HttpRequest.Instance.RequestHttpGet(url, HttpRequest.defaultHttpContentType, 1, OnGetServerList);
}
private void OnGetServerList(bool _ok, string _result)
{
if (_ok)
{
+ _result = _result.TrimStart('\uFEFF');
+ Debug.LogError("get server list string is " + _result);
ServerListParser.Instance.PushCommonServerListRawData(_result);
NetLinkWin.Hide();
}
else
{
+ Debug.LogError("failure to get server list " + _result);
Clock.AlarmAt(DateTime.Now + new TimeSpan(TimeSpan.TicksPerSecond), RequestServerCommonList);
}
}
@@ -295,9 +319,9 @@
}
}
- public void RequestServerListPlayer(string _accountName)
+ public async void RequestServerListPlayer(string _accountName)
{
- if (VersionUtility.Instance.InIosAuditTime())
+ if (await VersionUtility.Instance.InIosAuditTime())
{
return;
}
@@ -318,6 +342,8 @@
url = StringUtility.Concat(SERVERLIST_URL_PLAYER, "&", HttpRequest.HashtablaToString(tables));
}
+ // 鍔犳椂闂存埑闃叉娴忚鍣�/CDN缂撳瓨
+ url = StringUtility.Concat(url, "&_t=", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString());
HttpRequest.Instance.RequestHttpGet(url, HttpRequest.defaultHttpContentType, 1, OnGetServerListPlayer);
}
@@ -326,6 +352,7 @@
if (_ok)
{
serverListPlayerPartGot = true;
+ _result = _result.TrimStart('\uFEFF');
ServerListParser.Instance.PushPlayerServerListRawData(_result);
}
else
--
Gitblit v1.8.0