Currently whenever a user switches a page this code block is run immediatley:

```
// when the user disconnects.. perform this
socket.on('disconnect', function(){
    delete SiteRooms[socket.username];
    io.sockets.emit('updateusers', usernames);
    io.sockets.emit('updateroomusers', SiteRooms);
});

```

I do not want to run this if the user is only switching page on my site, is there some way i can do this?

I was thinking of a timer, maybe set it to 50 sec - maybe set it to 30 sec, if not present at the time: then disconnect. But i have no idea if this is a good solution nor how to write the actual code for it..

Any ideas?