Read the statement by Michael Teeuw here.
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:
test.js:Module.register("test",{ defaults:{ text:"Happy Birthday!!!!" }, getDom: function() { var wrapper = document.createElement("div"); wrapper.innerHTML =this.config.text; return wrapper; }, start:function(){ this.sendSocketNotification("main",{message:"test1"}); }, 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...'); this.function1(); } }, function1:function(){ console.log('inside function1'); this.sendSocketNotification("test2",{message:"test2"}); } });Here is config.js:
var config = { port: 8080, ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login