Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

TimHeckel commented Jan 10, 2013

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