Clean up after a closed EngineConnection (#304)
Because we gate a lot of things off this.foo?, leaving the closed websocket/pc/etc in-place was causing a noisy log, and mucking with reestablishing a broken connection. While I was in here, I fixed a style nit from yarn. Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io>
This commit is contained in:
@ -314,6 +314,9 @@ export class EngineConnection extends EventTarget {
|
||||
this.websocket?.close()
|
||||
this.pc?.close()
|
||||
this.lossyDataChannel?.close()
|
||||
this.websocket = undefined
|
||||
this.pc = undefined
|
||||
this.lossyDataChannel = undefined
|
||||
|
||||
this.dispatchEvent(
|
||||
new CustomEvent(EngineConnectionEvents.Close, {
|
||||
@ -375,7 +378,7 @@ export class EngineCommandManager {
|
||||
this.engineConnection.addEventListener(
|
||||
EngineConnectionEvents.ConnectionStarted,
|
||||
(event: Event) => {
|
||||
let customEvent = <CustomEvent<EngineConnection>>event
|
||||
let customEvent = event as CustomEvent<EngineConnection>
|
||||
let conn = customEvent.detail
|
||||
|
||||
this.engineConnection?.pc?.addEventListener('datachannel', (event) => {
|
||||
@ -421,7 +424,7 @@ export class EngineCommandManager {
|
||||
this.engineConnection.addEventListener(
|
||||
EngineConnectionEvents.NewTrack,
|
||||
(event: Event) => {
|
||||
let customEvent = <CustomEvent<NewTrackArgs>>event
|
||||
let customEvent = event as CustomEvent<NewTrackArgs>
|
||||
|
||||
let mediaStream = customEvent.detail.mediaStream
|
||||
console.log('received track', mediaStream)
|
||||
|
Reference in New Issue
Block a user