UserGuide

Web Push Updates

From Xojo Documentation

It is possible to have a user interface action on a page send out updates to all the clients that are currently connected to the web app.

In order to update your user interface via code, the update must be initiated by a user interface event such as an event of the web page, a button clicked event, etc. This means that if you want to update your user interface using data from the app (for example, data read from a socket or created by a XojoScript and then stored in a property of the application or Session classes), you will need to have a WebTimer control on a web page, container control or dialog, that fires and retrieves that information. The app itself, without a user interface event, cannot push data to the client.

Pushing Updates out to all Clients

If you want to broadcast information out to all clients (browsers) that are connected to your app, you can do so by retaining a reference to the pages you want to update.

Web Help Desk Chat Request

This still needs to be triggered by a user interface event, of course. For example, suppose you have a chat application and would like to broadcast a chat message from one user out to all the users with the chat app open in their browser.

Web Help Desk Chat Session

Each time a ChatPage is opened, you can add it to a global array on the App class. Then when a user sends a message (probably by clicking a send button), you can have the app loop through the chat pages that you have saved in the array and call a method on the page to display the message.

Help Desk Chat Web App

Example Projects

Some examples of this technique are included with Xojo:

  • Examples/Web/PushExample
  • Examples/Web/HelpDeskWithChat
  • Examples/Sample Applications/Chat

See Also

UserGuide:Web UI topic