Multi User/Session programming

Hi,

I am creating a web app that supports multi-users concurrently. One feature in particular, that some UI elements are “hot” linked. I.e. if one user makes a change, then that change immediately shows up for all other Users who are currently connected (i.e. have an active session).

One item, however, is very confusing to me. I am trying to get my head around it:

When in the code I call a method, how is it determined in what session it is running. Session seems to be a global object. And there is a session.identifier property that is unique for each session. In addition via the App object one can get a list of all current sessions.

But, how can a running method “know” under what session it is running? How is session context implemented?

thanks

Dan

p.s. I found a “work around” to this question, by saving the session identifier immediately after a session is created in a property associated with the main web app window (or more precisely with a controller object that is created and linked to that window). Like this every method in the controller can “know” what its session id is by querying the property. However, I would have thought that querying session.identifier would yield that information – however, it seems that it doesnt.

It’s a little bit tricky, but the short answer is threads. Every event from the browser starts up a thread to run, and when complete, the results are sent back to the browser. This thread knows which session created it. The Session call is actually a method which looks at the current thread’s session.