Keep list (and count) of online users in a Firebase web app - by isolated rooms or globally.
Let's create a new gathering
firebase.initializeApp({...});
var gathering = new Gathering(firebase.database(), 'A Room Name');Now you'll have the following functions and properties to work with -
gathering.join(uid, displayName)- Add me to gathering. Optionally can provide aunique idanddisplayName.gathering.leave()- Leave (that means remove myself from) the gatheringgathering.over()- Remove gathering from databasegathering.onUpdated(callback)- That function will be called (with user count and hash of users as param) every time the user list changedgathering.roomName- The gathering namegathering.myName- Current users's name in gathering, if joinedgathering.room- Firebase Database reference to the gathering room. Can be listened for removal or anything.
To see the usages in more details, please check the firebase-online-user-count-example.md file
sir,i am planning to store user registration details in firebase,so can i use your code to find number of users registred
thankyou sir