Skip to content

Instantly share code, notes, and snippets.

@mscandal
Created July 27, 2014 20:27
Show Gist options
  • Select an option

  • Save mscandal/55f5c97e5476df008f6a to your computer and use it in GitHub Desktop.

Select an option

Save mscandal/55f5c97e5476df008f6a to your computer and use it in GitHub Desktop.
var express = require('express');
var app = express();
var http = require('http');
var server = http.createServer(app);
var io = require('socket.io')(server);
app.use(express.static(__dirname + '/public'));
var paddle = require('./../paddle');
paddle.ready(function() {
io.on('connection', function(socket) {
paddle.button1(function(action) {
socket.emit('command', {
button1: action
});
});
paddle.button2(function(action) {
socket.emit('command', {
button2: action
});
});
paddle.wheel(10, function(voltage) {
socket.emit('command', {
wheel: 360 * (voltage + 1) / 1024
});
});
});
});
server.listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment