Created
July 17, 2012 12:40
-
-
Save ghtomcat/3129198 to your computer and use it in GitHub Desktop.
node.js server for EnyoSlides
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
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