Created
January 10, 2013 07:24
-
-
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.
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
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); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this might prove to be very useful...thank you!