Skip to content

Instantly share code, notes, and snippets.

@cjpartridgeb
Last active December 14, 2015 12:49
Show Gist options
  • Save cjpartridgeb/5089125 to your computer and use it in GitHub Desktop.
Save cjpartridgeb/5089125 to your computer and use it in GitHub Desktop.
tds5016
io.sockets.on('connection', function (socket) {
var timeout = false;
fs.watch('public/images/slides/', {}, function(eventType, filename){
if (eventType == 'change'){
if(timeout) clearTimeout(timeout);
timeout = setTimeout(function() {
var base64_data = new Buffer(fs.readFileSync('public/images/slides/'+filename)).toString('base64');
socket.emit('newSlide', base64_data);
}, 100);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment