Last active
January 14, 2019 19:42
-
-
Save aklinkert/8660031 to your computer and use it in GitHub Desktop.
Log all Sockets Events of an socket.io client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pre 1.0 | |
(function() { | |
var emit = socket.emit; | |
socket.emit = function() { | |
console.log('***','emit', Array.prototype.slice.call(arguments)); | |
emit.apply(socket, arguments); | |
}; | |
var $emit = socket.$emit; | |
socket.$emit = function() { | |
console.log('***','on',Array.prototype.slice.call(arguments)); | |
$emit.apply(socket, arguments); | |
}; | |
})(); | |
//post 1.0 | |
(function () { | |
var emit = socket.emit, | |
onevent = socket.onevent; | |
socket.emit = function () { | |
console.log('***', 'emit', Array.prototype.slice.call(arguments)); | |
emit.apply(socket, arguments); | |
}; | |
socket.onevent = function (packet) { | |
console.log('***', 'on', Array.prototype.slice.call(packet.data || [])); | |
onevent.apply(socket, arguments); | |
}; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment