client: ensure a proper init order for server-client communication
This commit is contained in:
parent
dc7ac2bcd3
commit
acf5f74ea2
3 changed files with 32 additions and 23 deletions
|
|
@ -2,7 +2,7 @@
|
|||
"name": "open-stage-control",
|
||||
"productName": "Open Stage Control",
|
||||
"description": "Libre and modular OSC / MIDI controller",
|
||||
"version": "1.30.0-beta4",
|
||||
"version": "1.30.0-beta5",
|
||||
"author": {
|
||||
"name": "Jean-Emmanuel Doucet",
|
||||
"email": "jean-emmanuel@ammd.net"
|
||||
|
|
|
|||
|
|
@ -13,18 +13,20 @@ function init() {
|
|||
|
||||
setTimeout(()=>{
|
||||
|
||||
ipc.init()
|
||||
ipc.init(()=>{
|
||||
|
||||
document.title = TITLE
|
||||
|
||||
ipc.send('open', {hotReload: backup.exists})
|
||||
document.title = TITLE
|
||||
|
||||
window.onunload = ()=>{
|
||||
ipc.send('close')
|
||||
}
|
||||
ipc.send('open', {hotReload: backup.exists})
|
||||
|
||||
backup.load()
|
||||
window.onunload = ()=>{
|
||||
ipc.send('close')
|
||||
}
|
||||
|
||||
backup.load()
|
||||
|
||||
})
|
||||
|
||||
}, 100)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ import cache from '../managers/cache.mjs'
|
|||
import {ENV} from '../globals.mjs'
|
||||
|
||||
var notifications, locales, callbacks
|
||||
;(async()=>{
|
||||
|
||||
var loadDeps = (async()=>{
|
||||
notifications = (await import('../ui/notifications.mjs')).default
|
||||
locales = (await import('../locales/index.mjs')).default
|
||||
callbacks = (await import('./callbacks.mjs')).default
|
||||
|
|
@ -49,24 +50,30 @@ class Ipc extends EventEmitter {
|
|||
|
||||
document.cookie = 'client_id=' + uuid + ';samesite=strict'
|
||||
|
||||
try {
|
||||
this.open()
|
||||
} catch(e) {
|
||||
console.warn('Could not open a WebSocket connection')
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
init() {
|
||||
init(callback) {
|
||||
|
||||
for (let i in callbacks) {
|
||||
let callback = callbacks[i]
|
||||
this.on(i, (data)=>{
|
||||
callback(data)
|
||||
})
|
||||
}
|
||||
loadDeps.then(()=>{
|
||||
|
||||
for (let i in callbacks) {
|
||||
let callback = callbacks[i]
|
||||
this.on(i, (data)=>{
|
||||
callback(data)
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
this.open()
|
||||
} catch(e) {
|
||||
console.warn('Could not open a WebSocket connection')
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
callback()
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue