Skip to content

Commit

Permalink
Fix minor semantics in waitForConnectedState
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen committed Nov 4, 2018
1 parent f0d1b04 commit 34a8296
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions webrtc/RTCTransport-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
// is "connected", all RTCIceTransports and RTCDtlsTransports are in the
// "connected", "completed" or "closed" state and at least one of them is in the
// "connected" or "completed" state.
function waitForConnectedState(pc) {
return new Promise((resolve, reject) => {
if (pc.connectionState === 'connected') {
resolve();
}
async function waitForConnectedState(pc) {
if (pc.connectionState === 'connected') return;

return new Promise((resolve, reject) => {
pc.addEventListener('connectionstatechange', () => {
const { connectionState } = pc;

Expand Down

0 comments on commit 34a8296

Please sign in to comment.