Skip to content

Commit

Permalink
fix: close event was not triggered reliably (#860)
Browse files Browse the repository at this point in the history
Closes #636
  • Loading branch information
jonasgloning committed May 25, 2022
2 parents 8816f54 + caddbb0 commit ec1d5ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/negotiator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export class Negotiator {
"iceConnectionState changed to disconnected on the connection with " +
peerId,
);
this.connection.close();
break;
case "completed":
peerConnection.onicecandidate = util.noop;
Expand Down
3 changes: 3 additions & 0 deletions lib/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ export class Peer extends EventEmitter<PeerEvents> {

if (index !== -1) {
connections.splice(index, 1);
if (connections.length <= 0) {
this._connections.delete(connection.peer);
}
}
}

Expand Down

0 comments on commit ec1d5ae

Please sign in to comment.