Perspective Send Message to all other opened clients

I am trying to push a message to all other opened clients when a button is pushed.

I have a script on my button:

projectName = system.util.getProjectName()
system.util.sendMessage(
	project = projectName, 
	messageHandler = 'pushUpdate', 
	payload = {'displayId': displayId},
	scope = 'S'
)

Then on the Session Events > Message > "pushUpdate":

system.perspective.sendMessage(
	messageType = 'getUpdate', 
	payload = payload, 
	scope = 'session'
)

log = system.util.getLogger('session event log')
log.info('session events message called')  # <-- This does show up in the logs.

Then on the view that I would like to listen for the getUpdate message:

system.perspective.print('gotUpdate') # <-- This does not show up in the client.

Yes, the Session scope is checked for this.

What am I missing?

Are all clients using the same session ? That seems unlikely to me.

Can you describe what you're trying to do ?

2 Likes

No. All clients would be using different computers in different parts of the plant. If a change is made in HQ, all clients with relevant information should be updated to show the updated info. I can't use tags.

Well, you've very clearly passed "session" as the scope. You can't expect OTHER sessions to receive the message too...

1 Like

Why not?
Alternatively, what triggers the update?

I can't because my client doesn't want it. I don't know why.

Actually, session is the correct scope for the system.util.sendMessage().

How is the getUpdate handler configured on the view?

It looks like OP is using system.perspective.sendMessage(), not util.sendMessage(), and in that case, the session scope is not sufficient for what OP wants.

EDIT oops I'm blind

He's using both actually.

I barely ever use the util one, I'll have to play with it a bit and see how it works before I can be of any help here.

1 Like

Are there any errors in the gateway logs? Is your event handler on your component expecting the message set to accept session scoped messages (by default they are only set to page level)

Man I need to read better. You might need to supply a pageId? But it says it should use the current page by default so I'm not sure. Are you sure your message handler on your view is called 'getUpdate' and not something else?

Every time I've had an issue with message handlers I find out I either got the name wrong or targeted a message handler that I changed the name of later.

First thoughts:

  1. Verify that the View you're working with is part of the same project as the originating broadcast done with the system.util call. It sounds like it since you're seeing the session-level logging, but I have to make sure.
  2. Is the View you're testing with open in a session outside the Designer? Message Handlers don't work within the Designer if I recall correctly.
  3. Is the View a Docked View? A Popup? For the View to hear the message, it MUST be present in the DOM of the browser. Collapsed Docked Views can be removed from the DOM depending on the configuration of the Page (if some other Docked View on the same side was the last one expanded for the side).

We have automated testing in place for this EXACT scenario, so there must be a logical explanation.