Hi Michelle - There’s no built-in way to do this so I would probably store the messages in a SQLite database (stored in the Shared Documents folder) and then have your code check that database for new messages.
There’s an example project in the Web folder (I think… not at the computer). It’s called something like Communicate with All Sessions. I use something like this in my XC web app when I’m about to push through an update. It sends all users logged in a message that there will be an update in about an hour and to save work and log out prior to then
Thanks for your answer. I do have the info stored in a database, but I need to notify all users immediately, even if they are editing another record, so I don’t want to poll the db.
The example provided shows how to notify users from all sessions connected to a single web app instance.
Michelle is asking to notify all users from all sessions in multiple web app instances ( eg in Xojo Cloud usually have more than one instances of the same app depending on the number of the cloud’s virtual CPUs)
Using the SQLite approach is good but all web app instances would have to pool the database from time to time for notification.
A faster way would be for each of the web app instances to log their ports ( eg: 8001, 8002, 8003, 8004) in the database and the initiating ( one that wants to make notification) web app ( eg: one running in 8002) would issue an http call to other instances ( 8001,8003,8004 obtained from the ports stored in the database) to initiate the notification plus doing the notification for itself internally.
Nothing is preventing you from opening more database connections. You can have one global connection that is not used by any session to do the polling. Once it sees the message, it does what it needs to with the sessions in its own instance.
If you’re using PostgreSQL, you could also use its notification system to achieve the same effect.