This project is read-only.

handling callback with multiple arguments using on

Jul 14, 2013 at 7:10 PM
I have a callback in js that goes like this that i want to translate into c# using socketio4net wondering if i would be able to do this by looking at the first argument (since objects are not all of the same type and a simple json.deserialize<objectname> wont work (or should i create a stub class with the members being all of the arguments and use that in the deserialize)

socket.on('someevent', function (arg1, arg2, arg3, arg4, arg5, arg6) {});

Jul 14, 2013 at 9:01 PM
I would create a stub class. I too started out returning multiple objects (the first iteration allowed you to return an array of various objects), however, I found it's much easier and less pain to return a single object, and go from there. So rather than 6 distinct objects, have a single object with 6+ different properties/objects within.

HTH - Jim
Jul 15, 2013 at 4:12 AM
Awesome, thanks jstott!