support custom origin for ws

This commit is contained in:
SrGooglo 2025-03-28 18:34:01 +00:00
parent 00237e3d31
commit 5e6371b5eb
2 changed files with 9 additions and 3 deletions

View File

@ -77,7 +77,9 @@ export function createClient({
if (typeof ws === "object") {
if (ws.enable === true) {
__comty_shared_state.ws = new WebsocketManager()
__comty_shared_state.ws = new WebsocketManager({
origin: origin,
})
if (ws.autoConnect === true) {
sharedState.ws.connectAll()

View File

@ -6,6 +6,10 @@ import { RTEngineClient } from "linebridge-client/src"
//import { RTEngineClient } from "../../linebridge/client/src"
class WebsocketManager {
constructor({ origin }) {
this.origin = origin
}
sockets = new Map()
async connect(remote) {
@ -23,7 +27,7 @@ class WebsocketManager {
}
}
const socket = io(Remotes.origin, opts)
const socket = io(this.origin, opts)
socket.on("connect", () => {
globalThis.__comty_shared_state.eventBus.emit(
@ -57,7 +61,7 @@ class WebsocketManager {
const client = new RTEngineClient({
refName: remote.namespace,
url: `${Remotes.origin}/${remote.namespace}`,
url: `${this.origin}/${remote.namespace}`,
token: Storage.engine.get("token"),
})