var wiimote = new Wii.Remote(1, {horizontal: true}), wiimote2 = new Wii.Remote(2, {horizontal: true}); wiimote.when('pressed_a', function() { alert('A Button on Wiimote 1 Pressed!'); }); wiimote2.when('pressed_a', function() { alert('Right Button on Wiimote 2 Pressed!'); });
var http = require('http'); function sendEvents(response) { response.write('id: ' + (new Date()).toLocaleTimeString() + '\n'); response.write('data: ' + (Math.floor(Math.random() * 10000) + 2) + '\n'); setTimeout(function() { sendEvents(response); }, 5000); } http.createServer(function(request, response) { response.writeHead(200, { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive' }); sendEvents(response); }).listen(8000);