Maybe a silly issue, but I'm trying to get a message handler on a component on any session of the 'message' project to execute and I'm not sure what I'm doing wrong.
I specifically want to trigger the message handler on a component in the session from a tag change script in my gateway, shown below.
system.util.sendMessage('message','test')
However I cannot get the component's message handler to execute. I also get no error logs in my gateway. I know my message handler is named 'test' and is listening for all scopes. I can get an identically named script in the session events to hear the message, but then I can't modify a component on the page using the payload (to my knowledge) since I'm at the session layer.
Does anyone see what I'm doing wrong or is this an impossible task and I'm not aware of it?
it definitely does, in this case though 'test' should be the messageType. trying to trim out variability, I'm just trying to see if I can get my message to the destination. Payloads will be next though
As @zacht mentioned, system.util.sendMessage will send a message from the gateway that, when expected to be received by a Perspective Component handler, requires an intermediate Session Message Handler under the projects Session Events.
From there, you will need to re-send a message using system.perspective.sendMessage, which will be broadcast from the Session to the components handler.
You're using system.util.sendMessage() so the first parameter is the "Project" name. Is your project actually named "message"?
To send messages in perspective, generally you would use the system.perspective.sendMessage() this would make the first parameter the message type, and the second parameter the payload, which would need to be a dictionary for it to work.
To send a message across sessions you would need something like this:
So I had been using system.util.sendMessage because I didn't think I would be able to use system.perspective.sendMessage from a tag change event script for some reason.
My goal in this is to be able to change a component property (on all active sessions of a given project) via a tag change event script that's built into a UDT. No idea if it's practical, but I thought it should be possible so I wanted to try it.
yeah, I just called it 'message' since it's kind of an experiment for me right now. So I can successfully message from a button using system.Util.sendMessage but only to the session events message handler. I will give just the system.perspective.sendMessage a try
The message handler listening for this message would need to be in the session events. Then from there you can use system.perspective.sendMessage() to target a specific componet,view,etc...
Sweet, so that makes me feel a lot better, as I had gotten to the point of messaging the session events successfully. It's just the handler there was still failing to execute the system.perspective.sendMessage portion of it.
Or rather, the handler I'm trying to target didn't receive the message, would be the more correct way to explain it.
I feel silly asking, but is my system.perspective.sendMessage just broken?
You should be including bindings to tags of interest in your session custom properties, and, if necessary, run a Perspective change event there.
Whenever you find yourself trying to "push" data to your user interface instead of letting your UI "subscribe" to the data the UI needs, step back and rethink what you are doing.