Created
March 30, 2012 15:57
-
-
Save maskit/2252422 to your computer and use it in GitHub Desktop.
WebSocket traffic sniffer
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
(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); | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How I send a custom data from this code?
Example:
var data = {"name": "subscribeEvent", "msg": {"name": "custom", "data": ""}}; this.send(data);