Skip to content

Instantly share code, notes, and snippets.

@maskit
Created March 30, 2012 15:57
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save maskit/2252422 to your computer and use it in GitHub Desktop.
Save maskit/2252422 to your computer and use it in GitHub Desktop.
WebSocket traffic sniffer
(function () {
WebSocket.prototype._send = WebSocket.prototype.send;
WebSocket.prototype.send = function (data) {
this._send(data);
this.addEventListener('message', function (msg) {
console.log('>> ' + msg.data);
}, false);
this.send = function (data) {
this._send(data);
console.log("<< " + data);
};
console.log("<< " + data);
}
})()
Copy link

ghost commented Apr 3, 2018

How I send a custom data from this code?
Example:
var data = {"name": "subscribeEvent", "msg": {"name": "custom", "data": ""}}; this.send(data);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment