I've read that OnDisconnect
( server side) sometimes , can be bypassed ( application recycle etc).
The OnDisconnected method doesn't get called in some scenarios, such as when a server goes down or the App Domain gets recycled.
And so I ask :
When a user connects , I generate him a token
, keep it in the user cookie
, and when OnConnect
is called , I attach a connectionId
with that token.
(the same way where onDiconnect
is called , I set a value in the dateDisconnected
)
This will also supports 2 connected users ( same browser)
example :
example :
id tokenId ConnectionID DateCreated dateDisconnected
----------------------------------------------------------------------------------------------
1 500 {1234-1234} 06-07-2013 null
2 500 {5432-5432} 06-07-2013 null
And here is the problem :
What will happen if a user has logged in (So I write this user in my DB as logged in) , do some chat , and then the server restarted ?
The client will try to reconnect and after 30 seconds it will stop.
But then , when the server is UP (after an hour ) - I STILL HAVE A LOGGED ON USER IN MY DB. and he is NOT. ( well , not with that connection ID anyway...)
How can I solve this kind of problem ?