Tag change script not sending to message handler

Hi everybody,

I’m trying to send a message to a perspective session for delogging session user.
From a boolean tag, I create a tag change script

project = "FX"
scope = "CP"
messageHandler = "logout"

In a perspective view, I create a message handler named “logout”
listen scope is Session and View
script is only

When changing the boolean tag, nothing happens

I also create a small button on the view, on configure event/onclick/script
system.perspective.logout() is logging out the perspective session

What can I be missing in my message handler properties ?

Thank you

I don’t believe that a Perspective view handler can receive messages from a Tag Change script as they are Gateway scoped.

Perspective doesn’t (yet) support message handling - you can send a message at the gateway level, but you aren’t able to receive that message in a Perspective session. The functionality should be available pretty soon, though - keep an eye on the nightly changelogs.

1 Like
  1. system.util.sendMessage has no defined scope of “CP”. You could use “CG”, but you don’t need to send a scope either.
  2. messageHandler in this context is the GATEWAY message handler, NOT the Perspective messageType.
  3. You might think that you could just switch over to system.perspective.sendMessage, but you can’t because tags have no concept of session.

Others have commented that perspective can’t receive messages form tags, and they’re correct, but you CAN send a message to the gateway, and the Gateway can send messages to sessions, BUT this all seems more complicated than it needs to be.

What you SHOULD do is bind a session property to a tag, something like session.custom.logUserOut to a tag path of “[tagProvider]/users/userName/logUserOut”.
Apply a property change script to the session property with the following code:

if currentValue.value is not None and currentValue.value:
1 Like

Regarding the “CP” scope, from the user manual the system.util.sendMessage indicates that his scope can be as follow

  • Scope

Gateway, Vision Client, Perspective Session

But the Perspective Session was not documented so I tried to imagine what can it be regarding the previous logic

I will try your solution
Thank you for your quick responses,

From the docs:

String scope - Optional. Limits the scope of the message delivery to “C” (clients), “G” (Gateway), or “CG” for clients and the Gateway. Defaults to “C” if the user name, role or host name parameters are set, and to “CG” if none of these parameters are set.

I wouldn’t recommend that. If something isn’t documented, then you’re probably using it incorrectly. In this case, scope has two different meanings/definitions between system.util.sendMessage and system.perspective.sendMessage. The util function scope argument determines where the message gets sent to, while the Perspective scope argument determines the level of hierarchy which may “hear” the message.

Any update on that

We’ve since introduced a way to use system.util.sendMessage where you can specify Perspective Sessions by supplying “S” as part of the scope.

1 Like