Skip to content
Snippets Groups Projects
Commit 152b136a authored by Kasalehlia's avatar Kasalehlia
Browse files

hardened calendar module

parent 45d0f234
No related branches found
No related tags found
No related merge requests found
......@@ -100,16 +100,23 @@ function getData(count, cb) {
}
module.exports = function (io) {
io.on('connect', function (sock) {
sock.emit('calendar', Mustache.render(TEMPLATE, CALENDAR));
});
function update() {
function update(firstRunCallback) {
getData(8, function (data) {
CALENDAR = data;
io.emit('calendar', Mustache.render(TEMPLATE, CALENDAR));
if (firstRunCallback) {
firstRunCallback()
firstRunCallback = null;
}
});
}
update();
update(function () {
var pushToClients = function (sock) {
sock.emit('calendar', Mustache.render(TEMPLATE, CALENDAR));
});
io.on('connect', pushToClients);
pushToClients(io);
});
setInterval(update, 600000);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment