0

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!

spacenick
  • 1,171
  • 3
  • 14
  • 19
  • 1
    As long as you're doing the ".onDisconnect().remove()" before you set any data there, it should reliably get removed. There might be a short delay (up to 3 to 5 minutes), but the data should eventually be removed. If you're seeing otherwise, I'd suggest pinging support@firebase.com with as much detail as you can provide. – Michael Lehenbauer Aug 01 '13 at 21:11
  • 2
    Also may be of help, check out the blog post on building a presence system: https://www.firebase.com/blog/2013-06-17-howto-build-a-presence-system.html to make sure you're covering all corner cases. – Anant Aug 02 '13 at 18:52

0 Answers0