mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-14 03:16:24 +00:00
set self._opts correctly
This commit is contained in:
parent
df8de6f608
commit
13e7ff7057
@ -24,6 +24,7 @@ function WebSocketTracker (client, announceUrl, opts) {
|
|||||||
|
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
|
self._opts = opts
|
||||||
self._announceUrl = announceUrl
|
self._announceUrl = announceUrl
|
||||||
self._peers = {} // peers (offer id -> peer)
|
self._peers = {} // peers (offer id -> peer)
|
||||||
self._ready = false
|
self._ready = false
|
||||||
@ -124,15 +125,15 @@ WebSocketTracker.prototype._onSocketMessage = function (data) {
|
|||||||
peer = new Peer({ trickle: false, config: self._opts.rtcConfig })
|
peer = new Peer({ trickle: false, config: self._opts.rtcConfig })
|
||||||
peer.id = common.binaryToHex(data.peer_id)
|
peer.id = common.binaryToHex(data.peer_id)
|
||||||
peer.once('signal', function (answer) {
|
peer.once('signal', function (answer) {
|
||||||
var opts = {
|
var params = {
|
||||||
info_hash: self.client._infoHash.toString('binary'),
|
info_hash: self.client._infoHash.toString('binary'),
|
||||||
peer_id: self.client._peerId.toString('binary'),
|
peer_id: self.client._peerId.toString('binary'),
|
||||||
to_peer_id: data.peer_id,
|
to_peer_id: data.peer_id,
|
||||||
answer: answer,
|
answer: answer,
|
||||||
offer_id: data.offer_id
|
offer_id: data.offer_id
|
||||||
}
|
}
|
||||||
if (self._trackerId) opts.trackerid = self._trackerId
|
if (self._trackerId) params.trackerid = self._trackerId
|
||||||
self._send(opts)
|
self._send(params)
|
||||||
})
|
})
|
||||||
peer.signal(data.offer)
|
peer.signal(data.offer)
|
||||||
self.client.emit('peer', peer)
|
self.client.emit('peer', peer)
|
||||||
@ -150,10 +151,10 @@ WebSocketTracker.prototype._onSocketMessage = function (data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebSocketTracker.prototype._send = function (opts) {
|
WebSocketTracker.prototype._send = function (params) {
|
||||||
var self = this
|
var self = this
|
||||||
debug('send %s', JSON.stringify(opts))
|
debug('send %s', JSON.stringify(params))
|
||||||
self._socket.send(opts)
|
self._socket.send(params)
|
||||||
}
|
}
|
||||||
|
|
||||||
WebSocketTracker.prototype._generateOffers = function (numWant, cb) {
|
WebSocketTracker.prototype._generateOffers = function (numWant, cb) {
|
||||||
|
Loading…
Reference in New Issue
Block a user