Looking for clarity around util.sendMessage() scopes

Hello all.

I'm a bit confused about the meaning of the various scope options provided by the system.util.sendMessage() function.

As the documentation states, the scope argument:

Limits the scope of the message delivery to "C" (clients), "G" (Gateway), "CG" for clients and the Gateway, or "S" Session. Any combination of C, G, and S are available. Defaults to "CS" if the user name, role, or host name parameters are set, and to "CGS" if none of these parameters are set. [optional]

Casually reading this left me pretty confused, especially coming from perspective.sendMessage(), which apparently accepts session as a scope argument but ignores it?

So I did some digging on the forums, which has mostly made me more confused because the terminology seems overloaded. I've gathered that for the purposes of sending a message from a view to all people with that view open I should be using the session scope in util.sendMessage(), but the answers I saw left me wondering what that scope actually is and why it is called a session scope.

Looking at the Designer, I can see that under Perspective there are Gateway Events and Session Events. It seems to me that I can create handlers more or less identically, though the Gateway Event has a lot more contextual information. I'm guessing that "Clients" are a Vision concept, which I am totally unfamiliar with.

If someone would be willing to explain each of the three scopes and how the messages reach handlers in detail I would be greatly appreciative.

Yes, the "Client" scope for system.util.sendMessage is purely for Vision clients. (Created back in the day, before Perspective was a gleam in IA's eye.)

system.util.sendMessage's Session scope only sends to session message handlers, not to any components.

system.perspective.sendMessage does not send to session message handlers, just to components. Its "session" scope is distinct.

I think I'm still confused about what a "session" is. When I read this page: Perspective Sessions | Ignition User Manual

I come away with the impression that a Session is started once per browser per project. A page is subordinate to that session, and so on.

Given that, I would think that the way util.sendMessage() works when targetting the session scope would be either:

  • The message is sent to a specific session ID that would need to be supplied. I think this is what perspective.sendMessage() does?
  • The message is broadcast across the entire gateway in a band that session event handlers have access to.

I believe it's the second for util.sendMessage(), now. But then what is the purpose of the gateway scope? When should I use it?

You would use util.sendMessage to gateway scope to:

  1. From a Vision client or Designer, invoke some action on the gateway (because their scripts run truly local to the machine where they are)
  2. Broadcast a message over the gateway network to another gateway entirely.