Skip to content

Instantly share code, notes, and snippets.

@belisarius222
Created January 10, 2013 07:24
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save belisarius222/4500183 to your computer and use it in GitHub Desktop.
Save belisarius222/4500183 to your computer and use it in GitHub Desktop.
patch client-side Meteor functions to print out the DDP messages. Add this somewhere in your client-side JS before Meteor.startup() and it should print out the DDP messages. Please let me know if there are some that are missing! I'm not sure I caught all of the handler functions.
var monkeyPatches = {
'_livedata_data': 'DATA',
'_livedata_error': 'ERROR',
'_livedata_nosub': 'NOSUB',
'_livedata_connected': 'CONNECTED',
'_livedata_result': 'RESULT',
};
_.each(_.keys(monkeyPatches),function(funcName){
var modifiedFunctionName = funcName+'_original';
var extension = {};
extension[modifiedFunctionName] = Meteor.default_connection[funcName];
_.extend(Meteor.default_connection, extension);
Meteor.default_connection[funcName] = function(msg){
console.log(monkeyPatches[funcName]+': ');
console.log(msg);
Meteor.default_connection[modifiedFunctionName](msg);
};
});
var originalSend = Meteor.default_connection._stream.send;
_.extend(Meteor.default_connection._stream,{
'originalSend': originalSend,
});
Meteor.default_connection._stream.send = function(data) {
console.log('SENDING: ');
console.log(JSON.parse(data));
Meteor.default_connection._stream.originalSend(data);
};
@TimHeckel
Copy link

this might prove to be very useful...thank you!

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