Hi,
I answer to myself as I could find the origin of the problem and correct it, maybe it could help others (as I didn’t see that implemented on many other module :winking_face: )
So the problem is documented on the developper doc here :
On socketNotificationReceived: function(notification, payload) part :
Note 1: When a node helper sends a notification, all modules of that module type receive the same notifications.
On this.sendSocketNotification(notification, payload) :
Note: Since all instances of your module will receive the notifications, it’s your task to make sure the right module responds to your messages.
So it is normal that each instance receive all the SocketNotification even send from another instance.
To manage this, I add on start function :
this.config.instanceID = this.identifier;
As all my socket notification send to the note_helper “self.config”, so the node_helper will know the source of the request and will be able to send it back on its answer.
Then on the node_helper sendSocketNotification, I send back this identifier with the corresponding answer.
And on the MMM_main.js, on the socketNotificationReceived, I start to check is the identifier correspond to this instance and if not :
return;
Unfortunatelly this was even not enough, in particular at start-up, when all instances want to receive their datas and request all the node_helper together with differents inputs, some mix up occurs, so I also had to implement a “initialDelay” timer (with setTimeout function) and I will ask the user to configure it correctly if he configure several instances.
So complicated solution (I feel…), but working fine !
Of course if anyone got a better one to share, please do !
Bye,
AgP