MagicMirror: this.sendSocketNotification is not a function

I have just about finished my Traffic module to get current commute time, but Iโ€™m having difficulty sending a socket notification other than the initial one in my start function. The project can be found here and the issue lies in MMM-Traffic.js.

I send a socket notification in start which queries the google maps api in node_helper.js then sends a socket notification back to MMM-Traffic.js which will then call updateDom(). Iโ€™m using updateCommute() as a proxy for setInterval that will send the initial socket notification at the user defined interval, but I am getting an error saying that this.sendSocketNotification is not a function. Any ideas?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 81 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Donโ€™t forget to add your module to the wiki, so that others can find it! Will give it a try later, thanks for your work!

Am 20.04.2016 um 09:58 schrieb Michael Teeuw notifications@github.com:

Great work @SamLewis0602! Iโ€™m using your module on my mirror. My girlfriend asked me for this features a few days ago! ๐Ÿ˜ƒ

I ended you a pull request with multi language support. This way it can be used in other languages as well.

Iโ€™ll continue further question/issues in your repro te keep everything in one place. ๐Ÿ˜ƒ

โ€” You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

@paviro: If in the handler itself you donโ€™t need the original this you can override it like this.

setTimeout(
  this.handler.bind(this),
  this.config.updateIntervall
);

or

setTimeout(
  function(){
    //doSomething
  }.bind(this),
  this.config.updateIntervall
);

Great! Everything is working now. Thanks again for your help!

(Until someone opens the interface twice in multiple browsers. Then the shit hits the fan. ๐Ÿ˜‰)

The Log.log helper does not work in the node helper as you might have noticed. ๐Ÿ˜ƒ

console.log(aVariable);

Should work.

Note: to send a notification from the node helper to the front end, the frontend first needs to send a message (to open the connection.)