Last active
December 15, 2015 09:19
-
-
Save gabrielhpugliese/5237342 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KEEPALIVE_INTERVAL = 5*1000; | |
Meteor.setInterval(function(){ | |
Meteor.call('keepalive'); | |
}, KEEPALIVE_INTERVAL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{#each friends}} | |
<li id="{{user_id}}" class="player-profile"> | |
<div class="friend-name"> | |
{{#if online user_id}} | |
<img src="images/online.png" /> | |
{{else}} | |
<img src="images/offline.png" /> | |
{{/if}} | |
<a data-toggle="modal" href="#profile-modal">{{name}}</a> | |
</div> | |
</li> | |
{{/each}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Template.index.online = function(user_id) { | |
return Connections.findOne({user_id: user_id}); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONNECTIONS_CLEANUP = 10*1000; | |
// this is server sided | |
Meteor.setInterval(function(){ | |
var now = +(new Date())/1000; | |
Connections.find({last_seen: {$lt: now - 10}}).forEach(function(conn){ | |
Connections.remove(conn['_id']); | |
}); | |
}, CONNECTIONS_CLEANUP); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment