From 03b880fdb37ad4e756893b2113b5097eeca98c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 11 May 2022 14:59:14 +0200 Subject: [PATCH] Web: also subscribe to current job when webapp starts --- web/app/src/components/UpdateListener.vue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/web/app/src/components/UpdateListener.vue b/web/app/src/components/UpdateListener.vue index 2a0d364b..dca55e85 100644 --- a/web/app/src/components/UpdateListener.vue +++ b/web/app/src/components/UpdateListener.vue @@ -60,9 +60,10 @@ export default { // console. window.ws = ws; - this.socket.on('open', (error) => { - console.log("socketIO connection open"); + this.socket.on('connect', (error) => { + console.log("socketIO connection established"); this.sockStatus.connected(); + this._resubscribe(); }); this.socket.on('connect_error', (error) => { // Don't log the error here, it's too long and noisy for regular logs. @@ -97,9 +98,7 @@ export default { this.socket.on("reconnect", (attemptNumber) => { console.log("socketIO reconnected after", attemptNumber, "attempts"); this.sockStatus.connected(); - - // Resubscribe to whatever we want to be subscribed to: - if (this.subscribedJob) this._updateJobSubscription("subscribe", this.subscribedJob); + this._resubscribe(); this.$emit("sioReconnected", attemptNumber); }); @@ -143,9 +142,14 @@ export default { _updateJobSubscription(operation, jobID) { const payload = new API.SocketIOSubscription(operation, "job", jobID); - console.log("sending job subscription:", payload); + console.log(`sending job ${operation}:`, payload); this.socket.emit("/subscription", payload); }, + + // Resubscribe to whatever we want to be subscribed to: + _resubscribe() { + if (this.subscribedJob) this._updateJobSubscription("subscribe", this.subscribedJob); + }, }, };