Session message handler not receiving a message from tag change

Hi everyone,

I’ve recently started working on ignition perspective and I’m having issues with raising a popup window on whatever page the user is on when there’s a fault.

I have a really simple setup as below:

on the tag that needs to be monitored, I have setup a script on value changed:

option 1, I tried the ‘session’ scope, but this is not ideal as I need the popup to appear on all sessions. It wasn’t really stable either, it works less than half of the time:

res = system.util.sendMessage(project="Test_Page",messageHandler="open_popup",payload={},scope="session",clientSessionId=res[0].value)

option 2, I tried the ‘client’ scope, but this didn’t work at all. Tried the “C” for scope as well, no joy:

res = system.util.sendMessage(project="Test_Page",messageHandler="open_popup",scope="client")

res is an empty list almost all the time but it returns the following when it works with option 1:

send message result: [type=Session,sessionId=90adb2cd-e7b2-4ad3-9479-659ad7881fef,project=Test_Page,messageHandler=open_popup,filterParams={clientSessionId=90adb2cd-e7b2-4ad3-9479-659ad7881fef, userRoles=, scope=S, userZones=},isRequest=no,sendStatus=SENT]

I have “open_popup” session message handler setup on Session Events in “Test_Page” project but the message handler almost never receives anything. Plan is to relay the message from here to a component using something like:

system.perspective.sendMessage('open_popup_card', payload)

It would be really appreciated if someone could point out what I am doing wrong or why it isn’t working.

Many thanks everyone.

okay.. for people who might run into the same issue that I had, I disabled then enabled the project again and now the session message handler is working. There were no errors or warnings in logs so it was really difficult to figure out what was going on.

There’s a lot going on here.

option 1, I tried the ‘session’ scope, but this is not ideal as I need the popup to appear on all sessions. It wasn’t really stable either, it works less than half of the time:

The docs suggest the scope argument value should be ”S” for Perspective Sessions. You can omit the clientSessionId if you want to send to all sessions.

This is the correct way to go; the Session proper has to receive the message, then relay it to the session. I don’t think you can omit the scope arg here because it defaults to “page”, and you’re not providing any pages; I’m pretty sure the scope here should be “session” (not “S”, because we’re in the Perspective package).

The problem, however, is that you claim you want this message to be opened in every session. For you to manage this, you need some universal component that is present on every page of your project. That component will need a message handler attached and that handler should consume the payload while listening to the Session scope - if you forget to listen on this scope, the component will never hear the message.

1 Like

And a docked view would be a suitable means of achieving this. If you don't need a docked view for anything else then add one and have it change to 1 pixel high (or whatever) on startup.

1 Like

hey guys,

Thanks a lot for the suggestions! I have managed to get the message to flow from tag value change script → session events message handler, I just need to figure out where to place the popup card component (which has a message handler to handle the system.perspective.openPopup) to consume the payload from session events message handler. Docked view sounds like a good place to try out, maybe I can add something to a footer and see how that turns out!

Or just set it to be onDemand (ie not shown on load) . All docks defined are always in the Dom and running, no matter if they're open or closed

5 Likes

Yeah, I just docked an empty view with message handler to the footer and set the size to 0. Working like a charm now :slight_smile:

2 Likes