Skip to content

Instantly share code, notes, and snippets.

@kevinswiber
Last active January 22, 2016 04:37
Show Gist options
  • Select an option

  • Save kevinswiber/3cc109330a623c4349ba to your computer and use it in GitHub Desktop.

Select an option

Save kevinswiber/3cc109330a623c4349ba to your computer and use it in GitHub Desktop.
Monitor data over Z2Z protocol.
module.exports = function(server) {
server.pubsub.subscribe('_peer/connect', function(ev, socket) {
if (!socket.peer.ws) {
return; // only use for initiating peer requests
}
var s = socket.peer.ws.socket;
var oldWrite = s.write;
s.write = function(data, encoding, callback) {
console.log('send:', data);
return oldWrite.call(s, data, encoding, callback);
}.bind(s);
s.on('data', function(d) {
console.log('recv:', d);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment