How to notify client from server side

Hi,

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:

  1. 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.
  2. 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.

1 Like

Have a look at this show and tell post: MQTT sample code

1 Like

Thank you very much Stefano and Owen!
I will study and test immediately these solutions

Best Regards

Thank you both once again!
I’ll start with timer and then will try the MQTT

This also seems like a situation that portable classes and their cache updates could help with: Anvil Docs | Cache Updates

1 Like

Alternatively, if you wanted to just use Anvil options, I think the Anvil-Extras Messaging component would probably work too: Messaging — Anvil Extras documentation

Thank you Jay!
Appreciated. I’ll read about it

Thanks Duncan! I’ll see it

Unfortunately, not. That module is client side only.

1 Like

Will an update be raised across multiple clients?

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?