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.
system.util.sendMessage has no defined scope of “CP”. You could use “CG”, but you don’t need to send a scope either.
messageHandler in this context is the GATEWAY message handler, NOT the Perspective messageType.
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:
system.perspective.logout()
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.