This commit is contained in:
retoor 2025-01-26 22:54:29 +01:00
parent 4ae846cf8b
commit fb7cb35921

View File

@ -208,9 +208,11 @@ class Socket extends EventHandler {
ws = null
isConnected = null
isConnecting = null
url = null
connectPromises = []
constructor() {
super()
this.url = window.location.hostname == 'localhost' ? 'ws://localhost/rpc.ws' : 'wss://' + window.location.hostname +'/rpc.ws'
this.ensureConnection()
}
_camelToSnake(str) {
@ -254,7 +256,8 @@ class Socket extends EventHandler {
}
return new Promise((resolve,reject)=>{
me.connectPromises.push(resolve)
const ws = new WebSocket("ws://localhost:8081/rpc.ws")
const ws = new WebSocket(this.url)
ws.onopen = (event) => {
me.ws = ws
me.isConnected = true