Skip to content

Instantly share code, notes, and snippets.

@NhanHo
Created February 9, 2016 02:13
Show Gist options
  • Save NhanHo/b2b6f3b0928a484b4a3a to your computer and use it in GitHub Desktop.
Save NhanHo/b2b6f3b0928a484b4a3a to your computer and use it in GitHub Desktop.
WebSocket.prototype._send = WebSocket.prototype.send;
WebSocket.prototype.send = function (data) {
this._send(data);
this.addEventListener('message', function (msg) {
if (msg.data.indexOf('console')>0) {
messages = (JSON.parse(JSON.parse(msg.data.substring(1))[0])[1]).messages.log;
for (msg in messages) {
console.log(messages[msg]);
}
};
}, false);
this.send = function (data) {
this._send(data);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment