2

Let's say I have 3 clients that are listening for changes on some firebase root. Each client represents themselves as a user in a List (or Map) on the root. I want to remove a user that loses their connection or closes their client app (i.e. stops listening). How can I detect when this happens and handle the change?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
clocksmith
  • 6,226
  • 3
  • 32
  • 45

1 Answers1

4

Super easy. Check out onDisconnect(). It can write data out to a node when the user disconnects or even update the value in a node. For example, on disconnect change the user status (maybe stored in your users node) to status:disconnected.

Jay
  • 34,438
  • 18
  • 52
  • 81