I’m new in Anvil and will appreciate advices on how to notify client from server side.
Is it possible the server to raise an event, which to be handled by the client? Searched the forum without success.
Here’s the business case:
A device collects temperatures from a few sensors, and is uplinked to Anvil server. Readings are downloaded and stored in table by the server module.
I want to send a signal from the server to the client, in order to refresh form’s items (and not only), whenever new data arrive.
Uplink is OK, table is initially populated by file upload, readings received and stored, but I don’t know how to start methods in the client module when new data is available on server (without user interaction).
The server cannot notify the client, but the client can use a timer to poll the server and ask if something has changed every few seconds.
You can add a timer, set its interval to a number of seconds that works for you and add the code to make a server call and get the latest news from the server on its tick event.
I have an app with a 3 second timer that shows the progress of a few uplink scripts. I keep it running 24/7 on my pc because I like to keep an eye on the uplink server, and other users use the same app to keep track of their tasks whenever they need.
Alternatively, if you wanted to just use Anvil options, I think the Anvil-Extras Messaging component would probably work too: Messaging — Anvil Extras documentation
Reiterating the same question to add clarity:
if person A and person B are on separate clients and person A pushes an update to the server that triggers a send_update, will that raise the set_update_handler for person B as well if it has set up a capability with the same permissions?