Open dbeulen opened 6 years ago
This is how I'm using it, is this what you're looking for?
firebase.addValueEventListener(data => {
if (data.value) {
console.log('Status: Online');
} else {
console.log('Status: Offline');
}
}, '.info/connected');
Although if you're trying to build a presence system, you might want to look at this link, as what you can do in the offline callback is limited (as you're offline): https://firebase.googleblog.com/2013/06/how-to-build-presence-system.html
Thank you for your reaction,
I already saw that website, and i'm trying to keep a database value if a user is online or offline. To do so i need these lines: (From the link)
var userRef = new Firebase('https://<demo>.firebaseio.com/presence/' + userid);
userRef.onDisconnect().set('☆ offline');
Do you also use this function?
Sorry to say I haven't. Think @EddyVerbruggen might be able to shed some more light on this, as it's beyond my limited abilities.
Did someone figure out a way to use onDisconnect?
Any updates on the topic? I have tried to use onDisconnect() with set/update/remove, but it throws that omDisconnect is not a function...
Indeed it isn't a function because it's not currently implemented (nor documented).
Is it possible to use the onDisconnect feature described on this website?
https://firebase.google.com/docs/database/web/offline-capabilities