Friendship
Friends Manager for your application, will manage relationships between userids and a socketid, which could b-e used with Socket.io to manage the online and offline friends in real time.
Getting Started
npm install friendship --save-dev
Create a friendship Manager
var Friendship = ; var friendship = expire: 3000 //auto checkouts in 3 seconds;
Register friends of user with id "uid1"
friendship;
CheckIn of a user with a Socket
friendship;
After the expire time (set on initialization), this socket will do a checkout
unless a .check()
is run before it.
Check to reset expiration
friendship;
Checkout of a user socket
friendship;
Can also run a checkout of all sockets that it could have:
friendship;
Unregister friends of a user
friendship;
This will run a checkout of all sockets and remove the user from any relationship. Can be used to make the user to an offline state on every socket.
TODO
- Add option to use Redis store.
- A way to clear all.
Contribute
- Fork this repo
- run
npm install
- Create the tests for the new functionality or bug case
- Put your awesome code
- run
grunt test
- All good?, place a pull request