Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ensure that 'peer' is emitted before 'connect' event fires
This is just a defensive code change to ensure that if signal() were somehow able to cause the peer to synchronously emit the 'connect' event that we won't cause the 'error' listener to be unregistered before 'peer' is emitted and the user has a chance to register their own 'error' listener
  • Loading branch information
feross committed Apr 12, 2021
commit dd02cddcb80e52d920f8ac889bbfc957020d3ab9
4 changes: 2 additions & 2 deletions lib/client/websocket-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,17 @@ class WebSocketTracker extends Tracker {
if (this._trackerId) params.trackerid = this._trackerId
this._send(params)
})
peer.signal(data.offer)
this.client.emit('peer', peer)
peer.signal(data.offer)
}

if (data.answer && data.peer_id) {
const offerId = common.binaryToHex(data.offer_id)
peer = this.peers[offerId]
if (peer) {
peer.id = common.binaryToHex(data.peer_id)
peer.signal(data.answer)
this.client.emit('peer', peer)
peer.signal(data.answer)

clearTimeout(peer.trackerTimeout)
peer.trackerTimeout = null
Expand Down