i am developing chat application using .net, here i have to re开发者_如何学JAVAfresh the online users periodically, is there any way please suggest me.
now i am getting user name once the user is logged in, and i am removing the user once he press the logout button, its ok and working fine, but some users just close their browser its not possible for me to identify whether he is in online or not, any help will be appreciated.
You can use some client side notification mechanism using stuff like AJAX (or ASP.NET AJAX). Have the client notify the server every 1-2 minutes to send a "I am alive" signal.
For a web app, Have a look at the Asp.NET AJAX Timer control (MSDN)
Also, see the JavaScript BODY onUnLoad event. It is fired when a browser window is closed or the user navigates away by changing the address bar URL or by clicking something etc.
For a form app, Have a look at the various timer controls
精彩评论