MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

sendSocketNotification is not working from node_helper to main module

  • Hi,

    I am new to node.js.I am trying to create new sample module “test”.I am sending notification from test module to node_helper and trying to receive notification back to test module.From test module to node_helper notification works fine, but test module does not receive any notification from node_helper.

    Here is my module code:

    		text:"Happy Birthday!!!!"
    	getDom: function() {
    		var wrapper = document.createElement("div");
    		wrapper.innerHTML =this.config.text;
    		return wrapper;
    	socketNotificationReceived: function(notification, payload) {
    		console.log('socketNotificationReceived() in main module..'+notification);
    		if (notification === "test2") {
    			console.log('test2 socket notification received...');

    Here is node_helper.js:

    var NodeHelper = require("node_helper");
    module.exports = NodeHelper.create({
    	// Override start method.
    	start: function() {
    	// Override socketNotificationReceived method.
    	socketNotificationReceived: function(notification, payload) {
    		var self=this;
    		console.log('*Starting socketNotificationReceived()*'+notification);
    		if (notification === "main") {
    			console.log(notification+' socket notification received...');
    		console.log('inside function1');

    Here is config.js:

    var config = {
    	port: 8080,
    	ipWhitelist: ["", "::ffff:", "::1"], // Set [] to allow all IP addresses.
    	language: "en",
    	timeFormat: 24,
    	units: "metric",
    	modules: [
    			module: "test",
    			position: "top_right"

    I am stuck there since last 3-4 days.If something is missing or wrong please correct me.Any help appreciated

Log in to reply