@@ -201,10 +201,8 @@ export default {
201201 device (device ) {
202202 if (device && this .isEditorAvailable ) {
203203 this .setContextDevice (device)
204- this .pollDeviceComms ()
205204 this .runInitialTease ()
206205 } else {
207- this .closeComms ()
208206 this .$router .push ({ name: ' device-overview' })
209207 .then (() => Alerts .emit (' Unable to connect to the Remote Instance' , ' warning' ))
210208 .catch (e => e)
@@ -232,9 +230,6 @@ export default {
232230 })
233231 .catch (err => err)
234232 },
235- beforeUnmount () {
236- this .closeComms ()
237- },
238233 methods: {
239234 ... mapActions (' context' , { setContextDevice: ' setDevice' }),
240235 loadDevice : async function () {
@@ -251,30 +246,6 @@ export default {
251246
252247 // todo we first need to get the device and set the team afterwards
253248 await this .$store .dispatch (' account/setTeam' , this .device .team .slug )
254- },
255- pollDeviceComms () {
256- if (! this .isEditorAvailable || this .ws ) return
257-
258- const uri = ` /api/v1/devices/${ this .device .id } /editor/proxy/comms`
259-
260- this .ws = new WebSocket (uri)
261-
262- this .ws .addEventListener (' error' , this .handleCommsDisconnect )
263- this .ws .addEventListener (' close' , this .handleCommsDisconnect )
264- },
265- handleCommsDisconnect (event ) {
266- console .warn (event )
267- this .$router .push ({ name: ' device-overview' })
268- .then (() => Alerts .emit (' Disconnected from remote instance.' , ' warning' ))
269- .catch (e => e)
270- },
271- closeComms () {
272- if (this .ws ) {
273- this .ws .removeEventListener (' error' , this .handleCommsDisconnect )
274- this .ws .removeEventListener (' close' , this .handleCommsDisconnect )
275- this .ws .close ()
276- this .ws = null
277- }
278249 }
279250 }
280251}
0 commit comments