FirstLegoLeague / displaySystem

Set of display tools
https://firstlegoleague.github.io/displaySystem/
4 stars 7 forks source link

When connected to MHub error: Fn is not defined #52

Closed kmeesters closed 6 years ago

kmeesters commented 6 years ago

I'm trying the following instance http://asia.display.fll-tools.com:1391/ When I don't connect to mhub (enter no or a wrong url in config.json) all the controls (in the 'c' window) work fine. But when connected to Mhub, every button in the control window generates the following error message:

modules/controls.js:44 Uncaught ReferenceError: fn is not defined
    at HTMLButtonElement.<anonymous> (http://asia.display.fll-tools.com:1391/modules/controls.js:44)
(anonymous) @ http://asia.display.fll-tools.com:1391/modules/controls.js:44

Any ideas what might be causing? Btw, this instance is running on node 9.2 on debian. (google compute) Btw2: triggering the clock from the other (clock) application does work (also trigger the clock in the display). I the control window has trouble sending the commands when using Mhub rather then directly?

kmeesters commented 6 years ago

Btw, this is the culprit:

function sendMessage(name,action,args,values) {
    var data = {};
    args.forEach(function(arg,i) {
        data[arg] = values[i];
    });
    system.ws.sendMessage({name:name},action,data);
}

function handleButton(module, f, inputs) {
    return function() {
        var data = inputs.map(getValue);
        if (system.ws && system.connected) {
            //handle via websocket
            sendMessage(name,fn,args,data);
        } else {
            //handle directly
            f.apply(module,data);
        }
    }
}

Specifically the sendMessage(name,fn,args,data);

poelstra commented 6 years ago

Fixed by #56.