mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 02:21: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)
|
self._onAnnounceStarted(params, peer, id)
|
||||||
} else if (params.event === 'stopped') {
|
} else if (params.event === 'stopped') {
|
||||||
self._onAnnounceStopped(params, peer, id)
|
self._onAnnounceStopped(params, peer, id)
|
||||||
|
if (!cb) return // when websocket is closed
|
||||||
} else if (params.event === 'completed') {
|
} else if (params.event === 'completed') {
|
||||||
self._onAnnounceCompleted(params, peer, id)
|
self._onAnnounceCompleted(params, peer, id)
|
||||||
} else if (params.event === 'update') {
|
} else if (params.event === 'update') {
|
||||||
|
@ -588,7 +588,7 @@ class Server extends EventEmitter {
|
|||||||
event: 'stopped',
|
event: 'stopped',
|
||||||
numwant: 0,
|
numwant: 0,
|
||||||
peer_id: socket.peerId
|
peer_id: socket.peerId
|
||||||
}, noop)
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@ function testRequestHandler (t, serverType) {
|
|||||||
class Swarm extends Server.Swarm {
|
class Swarm extends Server.Swarm {
|
||||||
announce (params, cb) {
|
announce (params, cb) {
|
||||||
super.announce(params, (err, response) => {
|
super.announce(params, (err, response) => {
|
||||||
if (err) return cb(response)
|
if (cb && err) return cb(response)
|
||||||
response.complete = 246
|
response.complete = 246
|
||||||
response.extraData = 'hi'
|
response.extraData = 'hi'
|
||||||
cb(null, response)
|
if (cb) cb(null, response)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user