Skip to content

Commit

Permalink
Fix #421. Fire RTCSession 'peerconnection' event as soon as its created
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillan committed Nov 5, 2017
1 parent b5e0784 commit 659e20a
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions lib/RTCSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,12 +658,6 @@ module.exports = class RTCSession extends EventEmitter
this._connection.addStream(stream);
}

debug('emit "peerconnection"');

this.emit('peerconnection', {
peerconnection : this._connection
});

if (! this._late_sdp)
{
const e = { originator: 'remote', type: 'offer', sdp: request.body };
Expand Down Expand Up @@ -1767,6 +1761,12 @@ module.exports = class RTCSession extends EventEmitter
});
}
});

debug('emit "peerconnection"');

this.emit('peerconnection', {
peerconnection : this._connection
});
}

_createLocalDescription(type, onSuccess, onFailure, constraints)
Expand Down Expand Up @@ -2501,14 +2501,6 @@ module.exports = class RTCSession extends EventEmitter
this._connection.addStream(stream);
}

debug('emit "peerconnection"');

// Notify the app with the RTCPeerConnection so it can do stuff on it
// before generating the offer.
this.emit('peerconnection', {
peerconnection : this._connection
});

this._connecting(this._request);
this._createLocalDescription('offer', rtcSucceeded.bind(this), rtcFailed.bind(this), rtcOfferConstraints);
}
Expand Down

0 comments on commit 659e20a

Please sign in to comment.