mirror of
https://github.com/ragestudio/comty.js.git
synced 2025-06-09 02:24:18 +00:00
support custom origin for ws
This commit is contained in:
parent
00237e3d31
commit
5e6371b5eb
@ -77,7 +77,9 @@ export function createClient({
|
|||||||
|
|
||||||
if (typeof ws === "object") {
|
if (typeof ws === "object") {
|
||||||
if (ws.enable === true) {
|
if (ws.enable === true) {
|
||||||
__comty_shared_state.ws = new WebsocketManager()
|
__comty_shared_state.ws = new WebsocketManager({
|
||||||
|
origin: origin,
|
||||||
|
})
|
||||||
|
|
||||||
if (ws.autoConnect === true) {
|
if (ws.autoConnect === true) {
|
||||||
sharedState.ws.connectAll()
|
sharedState.ws.connectAll()
|
||||||
|
@ -6,6 +6,10 @@ import { RTEngineClient } from "linebridge-client/src"
|
|||||||
//import { RTEngineClient } from "../../linebridge/client/src"
|
//import { RTEngineClient } from "../../linebridge/client/src"
|
||||||
|
|
||||||
class WebsocketManager {
|
class WebsocketManager {
|
||||||
|
constructor({ origin }) {
|
||||||
|
this.origin = origin
|
||||||
|
}
|
||||||
|
|
||||||
sockets = new Map()
|
sockets = new Map()
|
||||||
|
|
||||||
async connect(remote) {
|
async connect(remote) {
|
||||||
@ -23,7 +27,7 @@ class WebsocketManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const socket = io(Remotes.origin, opts)
|
const socket = io(this.origin, opts)
|
||||||
|
|
||||||
socket.on("connect", () => {
|
socket.on("connect", () => {
|
||||||
globalThis.__comty_shared_state.eventBus.emit(
|
globalThis.__comty_shared_state.eventBus.emit(
|
||||||
@ -57,7 +61,7 @@ class WebsocketManager {
|
|||||||
|
|
||||||
const client = new RTEngineClient({
|
const client = new RTEngineClient({
|
||||||
refName: remote.namespace,
|
refName: remote.namespace,
|
||||||
url: `${Remotes.origin}/${remote.namespace}`,
|
url: `${this.origin}/${remote.namespace}`,
|
||||||
token: Storage.engine.get("token"),
|
token: Storage.engine.get("token"),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user