fixes for simple-websocket@4

This commit is contained in:
Feross Aboukhadijeh 2016-02-15 19:36:47 -08:00
parent de234ac8b0
commit ad580c3d7c

View File

@ -128,8 +128,11 @@ WebSocketTracker.prototype._onSocketData = function (data) {
var self = this
if (self.destroyed) return
if (!(typeof data === 'object' && data !== null)) {
return self.client.emit('warning', new Error('Invalid tracker response'))
try {
data = JSON.parse(data)
} catch (err) {
self.client.emit('warning', new Error('Invalid tracker response'))
return
}
if (data.info_hash !== self.client._infoHashBinary) {