This project is read-only.

How to call socket.on('getObjects', function(callback)

May 13, 2014 at 9:12 PM
Edited May 13, 2014 at 10:23 PM
How can I call this method?
socket.on('getObjects', function(callback) {
    loggerlogger.verbose("socket.io <-- getObjects");
    callback(regaObjects);
});
see https://github.com/hobbyquaker/ccu.io/blob/master/ccu.io.js#L1756

I get always get a "Type Error" on server side.
Coordinator
May 13, 2014 at 10:17 PM
Normally, the socket event handler would look like this, with the client callback as the last parameter function. Have you checked to see how many params you have in the function handler - is 'callback' the only param passed, and is it a function?
socket.on('getObjects', function (data, callback) {
        var args = [].join.call(arguments, ':')
        logger.verbose("socket.io <-- getObjects");
        logger.verbose("getObjects <--  " + args);
        if (callback != 'undefined') {
            logger.verbose("getObjects  --> sending ack message via callback");
            callback(regaObjects);
        }
        else {
            logger.verbose(' ** expecting return function to call, but was missing?');
        }
    });
May 13, 2014 at 10:32 PM
Edited May 14, 2014 at 11:14 AM
I think my question was unclear, sorry.

I want to speak to this method from a 3rd Party Api, I cannpt modify the method, because it is used by others too.
socket.on('getObjects', function(callback) {
    loggerlogger.verbose("socket.io <-- getObjects");
    callback(regaObjects);
});
with your socketio4net.
And socketio4net provides this method
public void Emit(string eventName, dynamic payload, string endPoint = "", Action<dynamic> callback = null)
But I don't know which parameter to pass to this Emit method, I tried a function and action as payload, but it didn't work.