instead of a switch statement and parsing route, you can also just send functions as strings and have them be evaluated by the esp unit like so. (U can also use the eval function for this)
ws.on('message', function(msg) {
console.log(msg);
var command = new Function(msg);
command();
});
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
instead of a switch statement and parsing route, you can also just send functions as strings and have them be evaluated by the esp unit like so. (U can also use the eval function for this)