Unfortunately that’s not how this works. The only way a web app knows which session is currently “in context” is based on which thread is running and each session that is currently executing code has its own distinct thread.
Now, things like Timer, TCPSocket, UDPSocket, URLConnection, etc, all fire their asynchronous events on the main thread, that is, not associated with a particular session, regardless of where you place the control.
There are a couple of things you can do about this, but the simplest by far looks like this:
- Subclass URLConnection, add a Private String Property named SessionID and implement a Constructor in which you set this property to Session.Identfier.
- In the ContentReceived event, at the very top, put:
Var ctx as New WebSessionContext(App.SessionWithIdentifier(SessionID))
In that event, you should do the minimal amount of work you can to hand off the data to the session. For best results, I suggest just putting the HTTPStatus and the content into properties and use a WebTimer set to Single to process the data a moment later.