Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mllocs committed Aug 12, 2012
1 parent 7e20562 commit 9905cc0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 0 additions & 2 deletions client/application.css
@@ -1,7 +1,5 @@
/* CSS declarations go here */

@charset "utf-8";

div#container {
width: 240px;
margin: 30px auto 20px;
Expand Down
3 changes: 3 additions & 0 deletions client/users.js
Expand Up @@ -5,11 +5,14 @@

Meteor.startup(function() {

// Subscribe to users Collection
Meteor.subscribe("users");

// Create new user (since I'm not using any cookie I cannot identify retourning visitors)
user_id = Users.insert({name: '', last_keepalive: (new Date()).getTime()});
Session.set('user_id', user_id);

// Keep the user alive
Meteor.setInterval(function() {
if (Meteor.status().connected) {
Meteor.call('keepalive', Session.get('user_id'));
Expand Down
2 changes: 2 additions & 0 deletions server/users.js
Expand Up @@ -18,7 +18,9 @@ Meteor.methods({
keepalive: function (user_id) {
var now = (new Date()).getTime();
var remove_threshold = now - 8*1000;
// Updates current user last_keepalive attribute
Users.update({_id: user_id }, { $set: { last_keepalive: now } });
// Remove old users (this should be triggered in the server but I had some problems with it)
Users.remove({ 'last_keepalive': { $lt: remove_threshold }});
}
});
Expand Down

0 comments on commit 9905cc0

Please sign in to comment.