tags:

views:

9

answers:

0

Current setup: cometD servlet with jQuery cometd plugin.

Let's say i have a simple chat room that currently has 2 users (userA and userB) connected to it. When userB navigates away from the page, I need userA to be notified that userB has left the room. Is there a way to let userA know that userB left without using the unload handler?

$(window).unload(function(){
/** lets notify other users that currentUserId left **/

});

After conducting lots of tests; the above code block is not reliable.

The only solution i can think of is using a setInterval where every 1 minute, the admin will loop through an array of connected user, then "pings" them to check whether or not they're still connected.

Any ideas? Should i use the setInterval polling technique?