Send a msg from web dev to perspective msg handler and get the response

Hi
I want to create a simple API with web dev module so each time it receive GET request with below parameters , the endpoint send a message to a specific perspective message hander and receive the status of that component.

Ajax request <-> web dev <-> perspective event handler

Parameters:
session ID
Page ID
project name
component name

The problem the system.perspective.sendmessage() which is called from web dev endpoint doesn’t accept response from event handler and I don’t know how to send data back to web dev from event handler.

Thanks for any idea.

I don’t believe this is possible. Message Handlers have a scope that only refers to a session of Perspective. If a message is sent outside of a session, like a gateway script or Web Dev, there is no session scope for the message to be handled.

system.net.httpPost maybe has something usefull

I think you can call system.util.sendMessage from WebDev, then handle that message in Perspective Session Events, then from there, use system.perspective.sendMessage to send a message to Perspective sessions.

Try sending a CompletableFuture to Perspective and complete it in your Perspective message handler. Be sure to use a timeout in WebDev to deal with the message falling in the bitbucket on the floor.

1 Like