mirror of
https://github.com/Threnklyn/MinecraftChat.git
synced 2026-05-28 16:58:29 +02:00
Run the interval on the clientside instead of the server side
This commit is contained in:
@@ -2,6 +2,13 @@ module.exports = function($scope, socket) {
|
||||
|
||||
$scope.players = [];
|
||||
|
||||
// request player list every 5000ms
|
||||
setInterval(function() {
|
||||
socket.emit('players');
|
||||
}, 5000);
|
||||
|
||||
|
||||
// when the player list is received
|
||||
socket.on('bot:players', function(data) {
|
||||
var players = [];
|
||||
|
||||
@@ -15,12 +22,14 @@ module.exports = function($scope, socket) {
|
||||
|
||||
});
|
||||
|
||||
// clear player list if socket is disconnected
|
||||
socket.on('disconnect', function() {
|
||||
$scope.$apply(function() {
|
||||
$scope.players = [];
|
||||
});
|
||||
});
|
||||
|
||||
// clear player list when bot disconnects
|
||||
socket.on('bot:disconnect', function() {
|
||||
$scope.$apply(function() {
|
||||
$scope.players = [];
|
||||
|
||||
Reference in New Issue
Block a user