@strawberry-3.141 Thanks for the clarification. The code that I copied came from the node_helper as you are probably aware.
One more question for you concerning extending the socket with node_helper: The code you have for the MMM-mobile module is written like:
appSocket() {
const namespace =
${this.name}/app;
this.io.of(namespace).use((socket, next) => {
const hash = crypto.createHash('sha256').update(socket.handshake.query.token).digest('base64');
if (this.mobile.user && this.mobile.user === hash) {
console.log(`${this.name}: Access granted!`);
next();
} else {
console.log(`${this.name}: Authentication failed!`);
next(new Error('Authentication failed!'));
}
});
this.io.of(namespace).on('connection', (socket) => {
console.log(`${this.name}: App connected!`);
Mycroft in my case is on the same RPi so I realize the code will be different and you have created this code in a way to “pair” with the mobile device. Again, I am very new to writing code like this, but can you point in the right direction as far as how to extend the socket with the MMM-mycroft module’s node_helper.js? I do not understand how to extend the socket. Why is the code appSocket() {
const namespace =
${this.name}/app;
Would the same code work for MMM-mycroft module?
So my understanding, thanks to your help, to have a flow like this:
Node_helper extends socket server. Mycroft-core send command to node_helper, then the node_helper sends it to the MMM-mycroft module via this.send socketnotification and the MMM-mycroft module broadcasts it to all other modules via this.sendnotification.
I am just not sure how to code the Node_helper.js to extend the socket in my case.
You have been extremely helpful so far and I truly appreciate all of your help.
Also, since this is all done on the RPi, would the ipwhitelist even come into play here? My guess is no.