to manage presence with Firebase (with multiple windows open) I'm using that system where on every connection I'm pushing a random value to an array that I remove onDisconnect, and I basically check then if that array is null or not.
var ref = new Firebase('https://myfirebase.firebaseIO.com/{user_id}/online')
ref.push(new Date().getTime()).onDisconnect().remove()
It's working pretty great but I noticed sometimes in case of really bad network connectivity, the onDisconnect is not triggered and I'm ending up having ghost online users.
I've been thinking that having a kind of crontab cleaning up that data every X minutes could be a workaround but it seems a bit dirty.
Any ways to make that better?
Thanks!