mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 12:11:36 +00:00
fix: if websocket closed, don't produce a response
This commit is contained in:
parent
4699cc2da7
commit
ca88435617
@ -42,6 +42,7 @@ class Swarm {
|
||||
self._onAnnounceStarted(params, peer, id)
|
||||
} else if (params.event === 'stopped') {
|
||||
self._onAnnounceStopped(params, peer, id)
|
||||
if (!cb) return // when websocket is closed
|
||||
} else if (params.event === 'completed') {
|
||||
self._onAnnounceCompleted(params, peer, id)
|
||||
} else if (params.event === 'update') {
|
||||
|
@ -588,7 +588,7 @@ class Server extends EventEmitter {
|
||||
event: 'stopped',
|
||||
numwant: 0,
|
||||
peer_id: socket.peerId
|
||||
}, noop)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ function testRequestHandler (t, serverType) {
|
||||
class Swarm extends Server.Swarm {
|
||||
announce (params, cb) {
|
||||
super.announce(params, (err, response) => {
|
||||
if (err) return cb(response)
|
||||
if (cb && err) return cb(response)
|
||||
response.complete = 246
|
||||
response.extraData = 'hi'
|
||||
cb(null, response)
|
||||
if (cb) cb(null, response)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user