@wovoon/polaris 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +8 -2
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -143,9 +143,15 @@ export class PolarisClient {
|
|
|
143
143
|
emit("close", { error: "当前环境不支持 WebSocket" });
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
// CDN 加速域不支持 WebSocket:优先用入口页注入的 __wovoonRuntimeWsBase(平台主站,直连源站),
|
|
147
|
+
// 并以启动片段的 wovoon_play_sid 作为跨主机凭证(与 play cookie 同一游玩会话)。
|
|
148
|
+
const wsBase = String(globalThis.__wovoonRuntimeWsBase ?? "").replace(/\/+$/, "");
|
|
149
|
+
const origin = this.baseUrl || wsBase || `${location.protocol}//${location.host}`;
|
|
147
150
|
const scheme = origin.startsWith("https") ? "wss" : "ws";
|
|
148
|
-
|
|
151
|
+
const roomPath = `/api/cloud/rooms/${data.appId}/${encodeURIComponent(roomId)}`;
|
|
152
|
+
const sid = /[?&#]wovoon_play_sid=([0-9a-fA-F-]{36})(?:&|$)/.exec(String(location.hash ?? ""))?.[1];
|
|
153
|
+
const query = sid ? `${roomPath.includes("?") ? "&" : "?"}wovoon_play_sid=${sid}` : "";
|
|
154
|
+
socket = new WebSocket(`${scheme}://${origin.replace(/^https?:\/\//, "")}${roomPath}${query}`);
|
|
149
155
|
socket.onopen = () => { this.activeRooms.set(roomId, handle); };
|
|
150
156
|
socket.onmessage = (event) => {
|
|
151
157
|
let frame = null;
|