Read the statement by Michael Teeuw here.
what can i do in a module, porting from another mirror project
-
cool… that would allow my components to communicate in a synchronous mode…
-
do you have any pointers to examples of websockets from the module? or your “other JS code” means some OTHER library of JS code…
looks like I would have to build another js class to wrap the ws services…(run the server side in the helper) cause I can’t require() in the module itself… load those classes via the scripts…
-
@sdetweil A MagicMirror Module has two parts, the
node_helper.js
and any otherrequired
node.js modulewhich runs on your Raspberry Pi, the other part is just plain Javascript like in any Website running on the Browser (Electron in the default case).There are many node.js websocket server modules: https://www.npmjs.com/search?q=Websocket
Your
node_helper.js
is running the Websocket server and your other part is running a Websocket client. Follow this tutorial for the Websocket ClientThe communication won’t be encrypted in any way, so don’t pass importand information over the Websocket!
-
thanks… not a nodejs developer generally, so didn’t know about the npmjs site…
also, i run the MM on an ODROID not PI. a lot faster.
i understand how ws works… i built a custom ws server and interface in front of an api emulation platform to support software testing a couple years ago.
-
i have done some work over the weekend to get my two modules and their helpers working to do the basics…
database access is working, rest api server is working. (scheduler helper)
browser window creation and destruction is working, and image loading (handler helper)one thing of note, a json object transports from module to helper and back. BUT any data added to the object in the helper (like a browserwindow object), does NOT transport (becomes undefined on receipt.)
-
@sdetweil The module helper communication relies on a websocket connection. Any references will be lost. Try to clone the Object.
-
@idoodler thanks… i changed where the data is used and moved the routines to the node_helper… all good…
-
@sdetweil Glad I could help you!