Comments (1)
Basically there are three events on which you can register callbacks that run on the server to modify the status of a user, online, offline, and idle. Of the three states only the online and offline are automatic and for now the idle state is left up to you to implement if you want this functionality. The package is set up so that you can choose where to store the status. Some people still choose to store this in the user document. I prefer to create a profiles collection and have a record for each user and store this kind of information there. Below are examples taken from the README of the hooks you can register with.
//When the users status is online
UserPresence.onUserOnline(function(userId){
//update the profile for the user and set it's status to online
Meteor.profiles.update({userId:userId}, {$set:{status:"online"}})
});
//when the users status is set to idle
UserPresence.onUserIdle(function(userId){
//update the profile for the user and set it's status to idle
Meteor.profiles.update({userId:userId}, {$set:{status:"idle"}})
});
//when the users status is offline
UserPresence.onUserOffline(function(userId){
//update the profile for the user and unset it's status
Meteor.profiles.update({userId:userId}, {$unset:{status:true}})
});
I think this should help get you started.. Let me know if you need further help.
from socialize-user-presence.
Related Issues (14)
- Different package for user presence? HOT 2
- No userId in connection object HOT 2
- [Question] Support for React HOT 5
- Cannot read property 'RegEx' of undefined HOT 2
- HCP does not reflect server-side modified code changes HOT 2
- onUserOffline is not working HOT 4
- Incompatible with Meteor 2.3 HOT 5
- [Question] When is idle status activated? HOT 2
- Bug: user sessions are never properly cleaned up when a node dies HOT 4
- dependencies HOT 2
- Best way to keep track of where the user is using FlowRouter? HOT 4
- Undefined connection.userId HOT 4
- ReferenceError: determineStatus is not defined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socialize-user-presence.