I would like to have some sort of dashboard webpage in my web app
a simple listbox of all opened sessions and their user names
the user name is a property of the session object.
I can get all the sessions with : (LR excerpt)
For Each activeSession As WebSession In App.Sessions
but can I access the properties I added to my session object ?
it is not possible to subclass the Session object.
how can you do that ?
Hi, try with “as Session” instead of “as WebSession”, then I think you’ll be able to access those properties.
(I don’t have my computer at hand, but I think it should work)
For Each activeSession As Session In App.Sessions
@Ricardo_Cruz_Fernandez like this…
I’m not so sure that you can just do this, since this probably only works on the main thread. In web you must watchout since lot’s of stuff seems to be threaded by xojo.
@Greg_O_Lone can maybe explain what’s threaded?
- App.handleURL is threaded?
- Session is Threaded?
thanks @Ricardo_Cruz_Fernandez this seems to compile, and autocomplete gives my session properties.
It’s not a question of whether something is threaded or not, but whether or not there’s a session attached to the current thread.
If you’re curious about whether some code is running in a thread, you can look at App.CurrentThread. That’ll be a easier than me making a list, but I think you’ll find that usually things are, with the exception of things like socket and Timer events.
If this were me, I would be putting a Timer or Thread somewhere that’s initialized from App which periodically grabs this info. You can cycle through the sessions, creating and destroying WebSessionContexts as you go, just so you can pull the stats you need and store them in a global JSONItem which is retrieved from your dashboard periodically.