chore: Cleanup websocket/marshaller code
This commit is contained in:
parent
afbd1c3abe
commit
36c786a26d
|
|
@ -1,13 +0,0 @@
|
|||
export function initMarshaller () {
|
||||
window.addEventListener('EventOutputChunk', onOutputChunk)
|
||||
}
|
||||
|
||||
function onOutputChunk (evt) {
|
||||
const chunk = evt.payload
|
||||
|
||||
if (window.terminal) {
|
||||
if (chunk.executionTrackingId === window.terminal.executionTrackingId) {
|
||||
window.terminal.write(chunk.output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
import { buttonResults } from '../resources/vue/stores/buttonResults.js'
|
||||
|
||||
export function initWebsocket () {
|
||||
window.addEventListener('EventOutputChunk', onOutputChunk)
|
||||
|
||||
window.checkWebsocketConnection = checkWebsocketConnection
|
||||
}
|
||||
|
||||
export function checkWebsocketConnection () {
|
||||
reconnectWebsocket()
|
||||
}
|
||||
|
|
@ -47,3 +53,13 @@ function handleEvent (msg) {
|
|||
window.showBigError('ws-unhandled-message', 'handling websocket message', 'Unhandled websocket message type from server: ' + typeName, true)
|
||||
}
|
||||
}
|
||||
|
||||
function onOutputChunk (evt) {
|
||||
const chunk = evt.payload
|
||||
|
||||
if (window.terminal) {
|
||||
if (chunk.executionTrackingId === window.terminal.executionTrackingId) {
|
||||
window.terminal.write(chunk.output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,16 +15,11 @@ import { createApp } from 'vue'
|
|||
import router from './resources/vue/router.js'
|
||||
import App from './resources/vue/App.vue'
|
||||
|
||||
import {
|
||||
initMarshaller
|
||||
} from './js/marshaller.js'
|
||||
|
||||
import { checkWebsocketConnection } from './js/websocket.js'
|
||||
import { initWebsocket } from './js/websocket.js'
|
||||
|
||||
function initClient () {
|
||||
const transport = createConnectTransport({
|
||||
baseUrl: window.location.protocol + '//' + window.location.host + '/api/'
|
||||
|
||||
})
|
||||
|
||||
window.client = createClient(OliveTinApiService, transport)
|
||||
|
|
@ -40,15 +35,9 @@ function setupVue () {
|
|||
function main () {
|
||||
initClient()
|
||||
|
||||
// Expose websocket connection function globally so App.vue can call it after successful init
|
||||
window.checkWebsocketConnection = checkWebsocketConnection
|
||||
initWebsocket()
|
||||
|
||||
setupVue()
|
||||
|
||||
initMarshaller()
|
||||
|
||||
// window.addEventListener('EventConfigChanged', fetchGetDashboardComponents)
|
||||
// window.addEventListener('EventEntityChanged', fetchGetDashboardComponents)
|
||||
}
|
||||
|
||||
main() // call self
|
||||
main()
|
||||
|
|
|
|||
Loading…
Reference in New Issue