diff --git a/bundles/org.openhab.ui/web/build/webpack.config.js b/bundles/org.openhab.ui/web/build/webpack.config.js index 1df1015051..99646abb9e 100644 --- a/bundles/org.openhab.ui/web/build/webpack.config.js +++ b/bundles/org.openhab.ui/web/build/webpack.config.js @@ -69,15 +69,17 @@ module.exports = { ], allowedHosts: "all", historyApiFallback: true, - proxy: [{ - context: ['/auth', '/rest', '/chart', '/proxy', '/icon', '/static', '/changePassword', '/createApiToken', '/audio'], - target: apiBaseUrl - }, - { - context: "/ws/logs", - target: apiBaseUrl, - ws: true - }] + proxy: [ + { + context: ['/auth', '/rest', '/chart', '/proxy', '/icon', '/static', '/changePassword', '/createApiToken', '/audio'], + target: apiBaseUrl + }, + { + context: ['/ws/logs', '/ws/events'], + target: apiBaseUrl, + ws: true + } + ] }, performance: { maxAssetSize: 2048000, diff --git a/bundles/org.openhab.ui/web/src/pages/developer/developer-tools.vue b/bundles/org.openhab.ui/web/src/pages/developer/developer-tools.vue index bc4eecb861..97604fa19d 100644 --- a/bundles/org.openhab.ui/web/src/pages/developer/developer-tools.vue +++ b/bundles/org.openhab.ui/web/src/pages/developer/developer-tools.vue @@ -56,6 +56,7 @@ + @@ -63,7 +64,6 @@ Test SSE connection -

Start a SSE connection to check the different implementations

@@ -73,6 +73,24 @@
+ + + + + + + Test WebSocket connection + + + + + + + + + + + @@ -116,6 +134,8 @@ export default { currentTab: 'menu', sseClient: null, sseEvents: [], + wsClient: null, + wsEvents: [], icon: 'lightbulb', split: this.$device.desktop ? 'vertical' : 'horizontal' } @@ -135,6 +155,18 @@ export default { this.$oh.sse.close(this.sseClient) this.sseClient = null this.sseEvents = [] + }, + startWS () { + this.wsClient = this.$oh.ws.connect('/ws/events', (event) => { + event.time = new Date() + this.wsEvents.unshift(...[event]) + this.wsEvents.splice(5) + }) + }, + stopWS () { + this.$oh.ws.close(this.wsClient) + this.wsClient = null + this.wsEvents = [] } }, asyncComputed: {