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 id
anddisplayName
.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, is there a cdn link to this library to connect from client-side???