WebApplication: Global TCP Socket

Hi all,

n a Webapplication I have 3 WebPAges.

On Page1 (lets call it “Lobby”) I have a button which starts a TCP Connection of a TCPSocket which resides on Page2 (Hidden).
Lobby is the Initial Window Shown and it is shown all the time.

The TCP Socket has a method which checks the received message for some Chatmessages.

If Chatmessage has been received I want to send it to a TextArea on “Lobby”. But if I use lobby.methodtoaddchattext I get a NILObjectException on LOBBY when the function is called.

I want to have the TCPSocket on a “hidden” page, because later I have more than on Window and the User can switch from Lobby to e.g. Room1.

In Room1 I do some other stuff, but the TCPConnection should be the same.

How can I achieve a "global TCPSocket Object that could call methods on any possible WebPage?

Thanks for Help


Put it in the Session class?

That won’t work. Events on a socket fire on the main thread, and as such have no knowledge of which session they actually reside.

If what you are doing is simple, creating a WebSessionContext for the session in question may be an option, but there are known issues with creating and embedding new controls.

For more complex operations, I still suggest using a WebThread or a WebTimer connected to each session to poll for changes in the data that the socket stores on the session.