set self._opts correctly

This commit is contained in:
Feross Aboukhadijeh 2015-03-29 20:41:25 +13:00
parent df8de6f608
commit 13e7ff7057

View File

@ -24,6 +24,7 @@ function WebSocketTracker (client, announceUrl, opts) {
self.client = client
self._opts = opts
self._announceUrl = announceUrl
self._peers = {} // peers (offer id -> peer)
self._ready = false
@ -124,15 +125,15 @@ WebSocketTracker.prototype._onSocketMessage = function (data) {
peer = new Peer({ trickle: false, config: self._opts.rtcConfig })
peer.id = common.binaryToHex(data.peer_id)
peer.once('signal', function (answer) {
var opts = {
var params = {
info_hash: self.client._infoHash.toString('binary'),
peer_id: self.client._peerId.toString('binary'),
to_peer_id: data.peer_id,
answer: answer,
offer_id: data.offer_id
}
if (self._trackerId) opts.trackerid = self._trackerId
self._send(opts)
if (self._trackerId) params.trackerid = self._trackerId
self._send(params)
})
peer.signal(data.offer)
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
debug('send %s', JSON.stringify(opts))
self._socket.send(opts)
debug('send %s', JSON.stringify(params))
self._socket.send(params)
}
WebSocketTracker.prototype._generateOffers = function (numWant, cb) {