Overloading destroy method instead of having a separate method to remove video.

This commit is contained in:
David Négrier 2020-08-20 22:23:22 +02:00
parent 27ffb6b13d
commit 1162439479
3 changed files with 10 additions and 10 deletions

View file

@ -39,7 +39,7 @@ export class ScreenSharingPeer extends Peer {
});*/
this.on('close', () => {
this.closeScreenSharingConnection();
this.destroy();
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@ -79,16 +79,16 @@ export class ScreenSharingPeer extends Peer {
}
}
public closeScreenSharingConnection() {
public destroy(error?: Error): void {
try {
mediaManager.removeActiveScreenSharingVideo(this.userId);
// FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray"
// I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel.
//console.log('Closing connection with '+userId);
this.destroy();
super.destroy(error);
//console.log('Nb users in peerConnectionArray '+this.PeerConnectionArray.size);
} catch (err) {
console.error("closeConnection", err)
console.error("ScreenSharingPeer::destroy", err)
}
}

View file

@ -189,7 +189,7 @@ export class SimplePeer {
console.warn("Tried to close connection for user "+userId+" but could not find user")
return;
}
peer.closeConnection();
peer.destroy();
// FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray"
// I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel.
//console.log('Closing connection with '+userId);
@ -220,7 +220,7 @@ export class SimplePeer {
// FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray"
// I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel.
//console.log('Closing connection with '+userId);
peer.closeScreenSharingConnection();
peer.destroy();
this.PeerScreenSharingConnectionArray.delete(userId)
//console.log('Nb users in peerConnectionArray '+this.PeerConnectionArray.size);
} catch (err) {

View file

@ -39,7 +39,7 @@ export class VideoPeer extends Peer {
});*/
this.on('close', () => {
this.closeConnection();
this.destroy();
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@ -97,15 +97,15 @@ export class VideoPeer extends Peer {
/**
* This is triggered twice. Once by the server, and once by a remote client disconnecting
*/
public closeConnection() {
public destroy(error?: Error): void {
try {
mediaManager.removeActiveVideo(this.userId);
// FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray"
// I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel.
//console.log('Closing connection with '+userId);
this.destroy();
super.destroy(error);
} catch (err) {
console.error("closeConnection", err)
console.error("VideoPeer::destroy", err)
}
}