I'm doing a project using WebSockets at the moment and I have trouble making it 
work. I'm not sure I fully understand the problem. So here is my attempt in 
explaining what happens:

A tablet computer connects via WebSocket to a pharo image. On connection time a 
session object is created and a little later a user is associated to that 
session object. On login time I check if the user is already logged in to 
another tablet. This is by checking any session that has a user associated. So 
far so good.

In order to make the service reliable I test it by switching on/off the flight 
mode of the tablet just to simulate network problems. WebSockets use TCP and 
the problem appears that the server does not get notice that the connection 
went away. At the time the client reconnects it detects that there is an active 
session with a user and complains about it.

Handling of sessions is automatic. There are exception handlers that remove 
bogus sessions automatically. In order to solve the inactive session problem I 
do the following: If I find a session with a particular user I try to access 
the socket so an exception will be triggered if the connection isn't valid 
anymore. Theoretically it would work. 

When accessing the socket the exception isn't signalled in my current process 
but in the process that created the socket (I'm not 100% sure of this). The 
other process is suspended so the signalling does not occur. My second check 
for a session therefor sees that it is still there. But shortly after my 
process returns control the other process runs and removes the session from the 
list while handling the exception.

What would be a good way to tackle this? I tried a bit using yielding the 
active process, resuming the other process but all doesn't feel to be quite 
right to solve the problem. Is there a way to let the other process run or can 
I have the signalled exception in my current process? Anything else?

Any hints appreciated. Thanks,

Norbert

Reply via email to