Merge pull request #150 from feross/fix-148

Fix "Error: listener must be a function"
This commit is contained in:
Feross Aboukhadijeh 2016-04-22 16:43:02 -07:00
commit de1e206fec

View File

@ -713,13 +713,19 @@ Server.prototype._onWebSocketClose = function (socket) {
socket.peerId = null
socket.infoHashes = null
socket.removeListener('message', socket.onMessageBound)
if (typeof socket.onMessageBound === 'function') {
socket.removeListener('message', socket.onMessageBound)
}
socket.onMessageBound = null
socket.removeListener('error', socket.onErrorBound)
if (typeof socket.onErrorBound === 'function') {
socket.removeListener('error', socket.onErrorBound)
}
socket.onErrorBound = null
socket.removeListener('close', socket.onCloseBound)
if (typeof socket.onCloseBound === 'function') {
socket.removeListener('close', socket.onCloseBound)
}
socket.onCloseBound = null
}