diff --git a/lib/websocket-tracker.js b/lib/websocket-tracker.js index 59a8f94..f7ba1f3 100644 --- a/lib/websocket-tracker.js +++ b/lib/websocket-tracker.js @@ -25,7 +25,11 @@ function WebSocketTracker (client, announceUrl, opts) { self.destroyed = false self._opts = opts + self._announceUrl = announceUrl + if (self._announceUrl[self._announceUrl.length - 1] !== '/') self._announceUrl += '/' + self._announceUrl += '?' + hat(40) + self._peers = {} // peers (offer id -> peer) self._socket = null self._intervalMs = self.client._intervalMs // use client interval initially @@ -98,7 +102,7 @@ WebSocketTracker.prototype._openSocket = function () { self._onSocketDataBound = self._onSocketData.bind(self) self._onSocketCloseBound = self._onSocketClose.bind(self) - self._socket = new Socket(self._announceUrl + '?' + hat(40)) + self._socket = new Socket(self._announceUrl) self._socket.on('data', self._onSocketDataBound) self._socket.on('close', self._onSocketCloseBound) self._socket.on('error', self._onSocketErrorBound)