Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

fix: added peer connection state listener to emit closed events #134

Merged
merged 5 commits into from
Apr 25, 2023

Conversation

maschad
Copy link
Member

@maschad maschad commented Apr 20, 2023

The RTCPeerConnection state is not being monitored, as a result the peer:Disconnect event which is triggered by a connectionEnd event is not fired, resulting in closed connections not being properly propogated.

We can listen for disconnect events using the RTCPeerConnection connectionstatechange event

Closes: #138

src/transport.ts Outdated Show resolved Hide resolved
@maschad maschad marked this pull request as ready for review April 24, 2023 21:54
@p-shahi p-shahi requested a review from ckousik April 25, 2023 14:37
src/transport.ts Show resolved Hide resolved
@@ -183,13 +184,30 @@ export class WebRTCDirectTransport implements Transport {
}
}

const eventListeningName = isFirefox ? 'iceconnectionstatechange' : 'connectionstatechange'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally it's better to check if a capability is present or not. But that being said, I'm not sure off the top of my head how I would check for this. So I think it's okay.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, well iceconnectionstatechange event has been supported since Firefox 24 which is about a decade old, and connectionstatechange has been supported for at least two years in all other browsers, so I would say this is low risk.

src/transport.ts Outdated Show resolved Hide resolved
@maschad maschad requested a review from MarcoPolo April 25, 2023 18:46
@MarcoPolo MarcoPolo merged commit 16e8503 into main Apr 25, 2023
@MarcoPolo MarcoPolo deleted the fix/add-connectionstatechange-handler branch April 25, 2023 18:52
github-actions bot pushed a commit that referenced this pull request Apr 25, 2023
## [1.1.8](v1.1.7...v1.1.8) (2023-04-25)

### Bug Fixes

* added peer connection state listener to emit closed events ([#134](#134)) ([16e8503](16e8503)), closes [#138](#138) [#138](#138) [#138](#138)
@github-actions
Copy link

🎉 This PR is included in version 1.1.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disconnection events are not emitted
3 participants