Skip to content

Commit

Permalink
refactor: cleanup code
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <[email protected]>
  • Loading branch information
meteyou committed Sep 16, 2023
1 parent f928bb1 commit 8cdb957
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/components/webcams/WebrtcMediaMTX.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
this.terminate()
// clear any potentially open restart timeout
if (this.restartTimeout) {
clearTimeout(this.restartTimeout)
}
if (this.restartTimeout) clearTimeout(this.restartTimeout)
}
get webcamStyle() {
Expand Down Expand Up @@ -198,7 +196,7 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
.then((res) => this.onIceServers(res))
.catch((err) => {
this.log('error: ' + err)
//this.scheduleRestart();
this.scheduleRestart()
})
}
Expand Down Expand Up @@ -230,8 +228,6 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
this.offerData = this.parseOffer(offer.sdp ?? '')
this.pc?.setLocalDescription(offer)
this.log('sending offer', offer)
fetch(this.url, {
method: 'POST',
headers: {
Expand All @@ -240,9 +236,7 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
body: offer.sdp,
})
.then((res) => {
if (res.status !== 201) {
throw new Error('bad status code')
}
if (res.status !== 201) throw new Error('bad status code')
this.eTag = res.headers.get('E-Tag')
return res.text()
})
Expand All @@ -255,8 +249,8 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
)
})
.catch((err) => {
this.log('error: ' + err)
//this.scheduleRestart()
this.log(err)
this.scheduleRestart()
})
}
Expand Down Expand Up @@ -311,8 +305,8 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
if (res.status !== 204) throw new Error('bad status code')
})
.catch((err) => {
this.log('error: ' + err)
//this.scheduleRestart()
this.log(err)
this.scheduleRestart()
})
}
Expand All @@ -331,6 +325,7 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
this.terminate()
this.restartTimeout = window.setTimeout(() => {
this.log('scheduling restart')
this.restartTimeout = null
this.start()
}, this.RESTART_PAUSE)
Expand Down

0 comments on commit 8cdb957

Please sign in to comment.