HandleURL best practice - dataAvailable?

Hi all,

I have a working app that implements a rest like API response using HandleURL. I’m a little stuck on the best practice for using data as it arrives into HandleURL though.

At the moment I parse the response and send the response.Query to a property of the APP (sessions are not that important at the moment). The issue is that I am currently using a web timer to read that property and do something if there is a change. Is there an easy way to implement a dataAvailable event? I can’t call a method from within HandleURL as it is not in scope of the webpage doing the work. Thoughts all?

If you need to access a Session or WebPage directly, create a WebSessionContext before your code with the identifier of the session you are targeting. Then things like WebPage1 will work. Just having it in scope is enough to make it work.

If I’m understanding you correctly, if the referenced session has WebPage1 opened and WebPage1 has a property: “newData as String”, this code should work if placed in a “WebApplication.HandleURL” even handler?

Var context As New WebSessionContext(idOfTheSessionIWantToUpdate)
Var body as string = Request.Entity
Webpage1.newData = body

And Webpage1.newData in the referenced session will have the body of the request?? (i.e. just setting the “context” variable’s value with a reference to a valid session puts WebPage1 for this session “in scope”)

If so, this behavior doesn’t seem to be explicitly documented in the WebSessionContext entry of the online docs:

https://documentation.xojo.com/api/web/websession.htmlContext