This commit is contained in:
2026-07-24 01:37:11 +08:00
parent c91dbde7cb
commit d5c7ad40e3
12 changed files with 889 additions and 845 deletions
+10 -3
View File
@@ -32,12 +32,12 @@ namespace Assets.MyGame.Scripts.Net
//private const string baseUrl = "ws://game5241.wzaxr.top";
#if UNITY_EDITOR
private const string baseUrl = "ws://8.137.163.153";
//private const string baseUrl = "ws://8.137.8.46";
//private const string baseUrl = "ws://8.137.163.153";
private const string baseUrl = "ws://47.109.34.50";
#else
//private const string baseUrl = "ws://8.137.8.46";
private const string baseUrl = "ws://8.137.163.153";
private const string baseUrl = "ws://47.109.34.50";
#endif
public bool isGame = false;
@@ -117,6 +117,13 @@ namespace Assets.MyGame.Scripts.Net
socketUrls[type] = url;
handshakeActions[type] = action;
var ws = new WebSocket(new Uri(url));
// Best.WebSockets 1.22.3 bug:服务器返回 3xx 重定向时,InternalRequest_OnBeforeRedirection
// 会再次调用 StartOpen(),但实例已 open 过,抛 "Open already called!"。
// 这里禁用内部 HTTP 请求的重定向跟随来规避。
ws.OnInternalRequestCreated += (socket, req) =>
{
req.RedirectSettings.MaxRedirects = 0;
};
sockets[type] = ws;
// 事件绑定
ws.OnOpen += (web) =>