Trying to understand MessageManager.DataMessage


#1

I’m looking Message Manager library documentation again in the hope that things are a little clearer to me. The part that still has me baffled is the MessageManager.DataMessage object which gets returned when you use the MessageManager.send() method. I don’t understand how to use this as no examples given, in particular how to apply the various handlers, such as MessageManager.DataMessage.onAck();

So am I correct in understanding that a callback handler for MessageManager.onAck(function(msg) { … }), for example, will apply to all send messages used in the code, and then if I want to make customised onAck() relevant to a particular send event I would use something like

// assuming all configured correctly as per library example... local mm = MessageManager(); // Then assume for agent we have local msgEvent = mm.send("lights", true); // turn on the lights // Now I'll have a Datamessage object linked to msgEvent. So can now do something like msgEvent.DataMessage.onAck(function(msg) { ... });

#2

Ok I’ve been testing my logic and it appears I did not understand the message manager documentation. I got an error saying msgEvent.Datamessage does not exist.

I had to look at the library code to figure things out. So the way I see it, is that DataMessage is an internal or private class (if that is the correct way to say it) to the MessageManager class. So for documentation purposes do we really need to know about DataMessage.

What I did discover is that when setting Local msgEvent = mm.send(“lights”, true); it did in fact return an instance. Then I used msgEvent.onAck(function(msg) { … }); which provided me with an acknowledgement for that particular message send event.

So I assume this is the correct way to do things.

Any feedback greatly appreciated. Thanks