chore: OliveTin 3k progress

This commit is contained in:
jamesread
2025-08-03 22:10:51 +01:00
parent d4fe9eaa79
commit a62d58f119
85 changed files with 8660 additions and 7771 deletions

50
frontend/js/websocket.js Normal file
View File

@@ -0,0 +1,50 @@
import {
refreshServerConnectionLabel
} from './marshaller.js'
export function checkWebsocketConnection () {
reconnectWebsocket()
}
window.websocketAvailable = false
async function reconnectWebsocket () {
if (window.websocketAvailable) {
return
}
try {
window.websocketAvailable = true
for await (let e of window.client.eventStream()) {
handleEvent(e)
}
} catch (err) {
console.error('Websocket connection failed: ', err)
}
window.websocketAvailable = false
console.log('Reconnecting websocket...')
}
function handleEvent (msg) {
const typeName = msg.event.value.$typeName.replace('olivetin.api.v1.', '')
console.log("Websocket event receved: ", typeName)
const j = new Event(typeName)
j.payload = msg.event.value
switch (typeName) {
case 'EventOutputChunk':
case 'EventConfigChanged':
case 'EventEntityChanged':
case 'EventExecutionFinished':
case 'EventExecutionStarted':
window.dispatchEvent(j)
break
default:
console.warn('Unhandled websocket message type from server: ', typeName)
window.showBigError('ws-unhandled-message', 'handling websocket message', 'Unhandled websocket message type from server: ' + typeName, true)
}
}