mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 12:11:36 +00:00
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
This commit is contained in:
parent
ce8ea41f27
commit
dd02cddcb8
@ -278,8 +278,8 @@ class WebSocketTracker extends Tracker {
|
|||||||
if (this._trackerId) params.trackerid = this._trackerId
|
if (this._trackerId) params.trackerid = this._trackerId
|
||||||
this._send(params)
|
this._send(params)
|
||||||
})
|
})
|
||||||
peer.signal(data.offer)
|
|
||||||
this.client.emit('peer', peer)
|
this.client.emit('peer', peer)
|
||||||
|
peer.signal(data.offer)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.answer && data.peer_id) {
|
if (data.answer && data.peer_id) {
|
||||||
@ -287,8 +287,8 @@ class WebSocketTracker extends Tracker {
|
|||||||
peer = this.peers[offerId]
|
peer = this.peers[offerId]
|
||||||
if (peer) {
|
if (peer) {
|
||||||
peer.id = common.binaryToHex(data.peer_id)
|
peer.id = common.binaryToHex(data.peer_id)
|
||||||
peer.signal(data.answer)
|
|
||||||
this.client.emit('peer', peer)
|
this.client.emit('peer', peer)
|
||||||
|
peer.signal(data.answer)
|
||||||
|
|
||||||
clearTimeout(peer.trackerTimeout)
|
clearTimeout(peer.trackerTimeout)
|
||||||
peer.trackerTimeout = null
|
peer.trackerTimeout = null
|
||||||
|
Loading…
Reference in New Issue
Block a user