Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
node.js server for EnyoSlides
var io = require('socket.io').listen(8080);
console.log("listening on port 8080");
// Socket Routes
io.sockets.on('connection', function (socket) {
socket.on('setPresenter', function(){
socket.set('presenter', true, function(){
socket.emit('ready');
});
});
socket.on('slideChanged', function(slideIndex){
socket.get('presenter', function(err, isPresenter){
if(isPresenter){
io.sockets['in']('viewers').emit('changeSlide', slideIndex);
}
});
});
socket.on('joinViewer', function(){
socket.join('viewers');
});
socket.on('leaveViewer', function(){
socket.leave('viewers');
});
socket.on('newQuestion', function(question){
if(question.name && question.question){
question.name = question.name.trim();
question.question = question.question.trim();
socket.emit('updateQuestions', question);
socket.broadcast.emit('updateQuestions', question);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.