Ideas: How to live update a web page from HandleURL Post messages

Looking for ideas for an easy way to live update a web page using a stand alone Web 2.0 app, when the app receives POST messages from an external source.

Essentially I want the user to be able to view a “Status” page, and without continually refreshing it, have it update with information which comes from systems using outbound Webhooks to send it POST requests with the data in.

So, for example, a screen showing live call data from a telephone switchboard. To show when a call starts, ends etc, so that I can automatically look up customer data and display it when a call comes in via the POST web hook message sent from the switchboard.

Also, to be used for other “live” incoming data.

Hope that makes sense!

Hi Richard. Well if you process any new data whatsoever you can update any control on the current page and it will refresh that control w/out the user refreshing the page. Try using a simple Timer control, and in the action have it update a simple label on the page - you’ll see the label change with the rest of the page remains undisturbed.

The problem is, the POST data will come in by itself into a HandleURL event, and then somehow that has to “Push” an update to a page which is already being viewed by a user. The page the user is viewing can’t “Pull” the data, because that comes in by itself live from external systems.

You could place the new data in the database and periodically poll the DB for changes.

You could loop through the active sessions by using the App.Session* methods, then call a method within the context of the appropriate Session once you find it.

I need the data to be “pushed” as it’s live data and not stored, most of it will be coming from web hooks out of a phone system, so I want the page to show live call data, nothing needs to be stored. Can I update a Window being displayed as part of a session?

You can. You could have a method on your Session called something like “UpdatePage(withData as JSONItem)”, find the correct session based on whatever criteria your app uses, such as a UserID property on the Session object, then in the UpdatePage method you’ll push the changes to the page(s).

Ah ok, that gives me some ideas, ideally anyone with a certain page displayed would get the update, so if 6 people are viewing the status page and a web hook comes in via HandleURL then all 6 pages could be updated, so everyone sees what’s happening. So, if I can do that without every user having to keep continually refreshing their page (either themselves or via a timer) that would be awesome. Then this technique could be used to create all sorts of Status pages which update themselves from external sources.

Should be doable. I don’t have any code or an example project handy as I implemented this a few times for customers in Web 1.0 but haven’t had the need for Web 2.0 yet.

Good luck!

Thanks, haven’t done anything other than a little thing in 2.0, all my stuff is in 1.0, but I want to try and move forward with the 2.0 version. Nothing I come up with is ever simple! I’ll test it first just by using another web browser to create the URL calls for the HandleURL, but eventually they’ll come in via a POST

I guarantee this 100% works and you’ll be stoked! I’m already doing it, so I’m positive it works. :slight_smile:

Hi Richard,

I used this principle in web 1.0 for webhooks from payment processor (naturally can be used for whatever) and so the apps purpose in life is to simply churn out all of the passed parameters, displaying on the webpage, payload etc and also some ready Xojo code:

The (1.0) principle for this is like the below:

if app.SessionCount > 0 then
  for n as integer = 0 to (app.sessioncount -1)
    dim sess as session = app.SessionAtIndex(n)
    dim wc as WebControl
    dim p as webpage
    p = sess.PageWithName("WebPage1", true)
    if p <> nil then

    wc = sess.PageWithName("WebPage1", true).ControlWithName("TextArea1")

    // Now do something with the control - in my case, displaying the above stuff

Note the above principle should have the caveat that this will work (as-is) for a single instance. Multi instance then you have more considerations aka it gets a bit harder.


EDIT: All dummy sandbox data in case anyone is wondering :slight_smile:

Once you have p, is not better to use it?

if p <> nil then
    wc = p.ControlWithName("TextArea1")

Absolutely :slight_smile:


You can’t just reach into a session and expect this to work consistently without creating a WebSessionContext object first.

Right after the line where you grab the session, you’d need to create it:

dim sess as session = app.SessionAtIndex(n)
Dim ctx as new WebSessionContext(sess.identifier)

It just needs to stay around long enough to process the changes for that session.


Thanks for all the great ideas, much appreciated, gives me a lot to look at and work with. Once I can get something up and running I can use it for a whole range of web hook processing which would be very useful.

Greg’s reply, regarding using WebSessionContext, is critical.

When we were starting out with Web Applications, it took a little while to understand the relationship between the App and the Sessions. HandleURL responds to requests that are outside the scope of any and all Sessions. If the app needs to interact with a specific Session, or iterate through all Sessions, the WebSessionContext is used to “connect” to the Session and then implement the desired functionality.

Hope that helps.

It sure does, thanks, much appreciate all the great feedback and ideas on this one :slight_smile: