<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Unable to sendSocketNotification from node_helper to Module]]></title><description><![CDATA[<p dir="auto">Hi community, I’m pulling my hair out trying to get this one working.</p>
<p dir="auto">I’ve got my <a href="https://github.com/jc21/MMM-IFTTT" target="_blank" rel="noopener noreferrer nofollow ugc">MMM-IFTTT</a> module nearly completed, except for a small hickup.</p>
<p dir="auto">In the node_helper.js I’m sending a socket notification that is not getting through to the UI. It was working at some stage before nesting it in another function, so I assume it’s a scope issue. I’ve tried debugging everything everywhere, even using <code>this.io</code> to send it the hard way.</p>
<p dir="auto">I’m using the new ES6 anonymous function syntax, ie:</p>
<pre><code class="language-javascript">this.expressApp.post('/IFTTT', (req, res) =&gt; {
</code></pre>
<p dir="auto">which should keep the <code>this</code> reference from outside of the function and all my console logging suggests it does, however I think that the <code>io</code> reference is not the same one somehow, and despite the <code>this.io.of(this.name).emit(notification, payload);</code> succeeding in the node helper library, the notification simply doesn’t show in the UI dev console.</p>
<p dir="auto">This is also apparent when trying the <code>var self = this;</code> method, using the <code>self</code> object even immediately doesn’t send through the socket.</p>
<p dir="auto">Any help on this scope stuff would be appreciated! Thanks in advance.</p>
<pre><code class="language-bash">Raspbian Jessie
Node version: v6.6.0
</code></pre>
]]></description><link>https://forum.magicmirror.builders/topic/661/unable-to-sendsocketnotification-from-node_helper-to-module</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 10:04:13 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/661.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 Sep 2016 06:27:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Unable to sendSocketNotification from node_helper to Module on Mon, 19 Sep 2016 09:44:14 GMT]]></title><description><![CDATA[<p dir="auto">Wow that is not obvious or documented.</p>
<p dir="auto">However, that worked :) Thanks heaps!</p>
]]></description><link>https://forum.magicmirror.builders/post/5018</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/5018</guid><dc:creator><![CDATA[jc21]]></dc:creator><pubDate>Mon, 19 Sep 2016 09:44:14 GMT</pubDate></item><item><title><![CDATA[Reply to Unable to sendSocketNotification from node_helper to Module on Mon, 19 Sep 2016 09:30:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jc21" aria-label="Profile: jc21">@<bdi>jc21</bdi></a> If I’m right you must start the connection from the module, but can’t test it right now</p>
<p dir="auto">MMM-IFTTT.js</p>
<pre><code>start: function() {
        this.sendSocketNotification('START', {message: 'start connection'});
},

socketNotificationReceived: function(notification, payload) {
        if (notification === 'MSG'){
            Log.info(payload);
        }
    },
</code></pre>
<p dir="auto">node_helper.js</p>
<pre><code>const NodeHelper = require('node_helper');

module.exports = NodeHelper.create({
    start: function() {
        console.log('[IFTTT] Starting node_helper');
    },

    socketNotificationReceived: function(notification, payload) {
        if (notification === 'START'){
            setTimeout(() =&gt; {
                this.sendSocketNotification('MSG', {message: 'test'});
             }, 10000);
        }
    },
});
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/5016</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/5016</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Mon, 19 Sep 2016 09:30:32 GMT</pubDate></item><item><title><![CDATA[Reply to Unable to sendSocketNotification from node_helper to Module on Mon, 19 Sep 2016 08:35:32 GMT]]></title><description><![CDATA[<p dir="auto">I dumbed the module right down:</p>
<p dir="auto"><code>node_helper.js</code></p>
<pre><code class="language-javascript">const NodeHelper = require('node_helper');

module.exports = NodeHelper.create({
    start: function() {
        console.log('[IFTTT] Starting node_helper');

        var self = this;
        setTimeout(function () {
            self.sendSocketNotification('MSG', {message: 'test'});
        }, 10000);
    }
});
</code></pre>
<p dir="auto"><code>MMM-IFTTT.js</code></p>
<pre><code class="language-javascript">//...
    socketNotificationReceived: function(notification, payload) {
        if (notification === 'MSG'){
            Log.info(payload);
        }
    },
//...
</code></pre>
<p dir="auto">Still not getting the log in dev console :(</p>
]]></description><link>https://forum.magicmirror.builders/post/5015</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/5015</guid><dc:creator><![CDATA[jc21]]></dc:creator><pubDate>Mon, 19 Sep 2016 08:35:32 GMT</pubDate></item><item><title><![CDATA[Reply to Unable to sendSocketNotification from node_helper to Module on Mon, 19 Sep 2016 08:21:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jc21" aria-label="Profile: jc21">@<bdi>jc21</bdi></a> did you try the common way?</p>
<pre><code>this.sendSocketNotification('MSG', 'Hello World');
</code></pre>
<p dir="auto">and in the module itself</p>
<pre><code>socketNotificationReceived: function(notification, payload){
    if(notification === 'MSG'){
        Log.info(payload);
    }
}
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/5014</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/5014</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Mon, 19 Sep 2016 08:21:18 GMT</pubDate></item></channel></rss>