mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-14 03:16:24 +00:00
fix exception in websocket tracker
This commit is contained in:
parent
fdb94e98d7
commit
da5036424b
@ -44,6 +44,7 @@ function HTTPTracker (client, announceUrl, opts) {
|
||||
|
||||
HTTPTracker.prototype.announce = function (opts) {
|
||||
var self = this
|
||||
if (self.destroyed) return
|
||||
if (self._trackerId) opts.trackerid = self._trackerId
|
||||
|
||||
if (opts.compact == null) opts.compact = 1
|
||||
@ -58,6 +59,7 @@ HTTPTracker.prototype.announce = function (opts) {
|
||||
|
||||
HTTPTracker.prototype.scrape = function (opts) {
|
||||
var self = this
|
||||
if (self.destroyed) return
|
||||
|
||||
if (!self._scrapeUrl) {
|
||||
self.client.emit('error', new Error('scrape not supported ' + self._announceUrl))
|
||||
|
@ -39,11 +39,13 @@ function UDPTracker (client, announceUrl, opts) {
|
||||
|
||||
UDPTracker.prototype.announce = function (opts) {
|
||||
var self = this
|
||||
if (self.destroyed) return
|
||||
self._request(opts)
|
||||
}
|
||||
|
||||
UDPTracker.prototype.scrape = function (opts) {
|
||||
var self = this
|
||||
if (self.destroyed) return
|
||||
opts._scrape = true
|
||||
self._request(opts) // udp scrape uses same announce url
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ function WebSocketTracker (client, announceUrl, opts) {
|
||||
|
||||
WebSocketTracker.prototype.announce = function (opts) {
|
||||
var self = this
|
||||
if (self.destroyed) return
|
||||
if (!self._socket.connected) {
|
||||
return self._socket.once('connect', self.announce.bind(self, opts))
|
||||
}
|
||||
@ -69,6 +70,7 @@ WebSocketTracker.prototype.announce = function (opts) {
|
||||
|
||||
WebSocketTracker.prototype.scrape = function (opts) {
|
||||
var self = this
|
||||
if (self.destroyed) return
|
||||
self._onSocketError(new Error('scrape not supported ' + self._announceUrl))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user