Last active
September 10, 2015 12:34
-
-
Save stefania11/af88b0aa5bdb7480f045 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//general call in express for socket connection// | |
var app = require('express')(); | |
var server = require('http').createServer(app); | |
var io = require('socket.io')(server); | |
io.on('connection', function(){ /* … */ }); | |
server.listen(3000); | |
//example from how we use it in Michael Says// | |
if (_socketEnabled) { | |
var socket = io.connect('http://localhost:3000'); | |
socket.on('news', function (data) { | |
console.log(data); | |
}); | |
socket.on('hit', function (data) { | |
console.log(data.sound); | |
console.log(typeof data.sound); | |
if(data.sound == 1){ | |
hit1(); | |
} | |
// more code here for every key// | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment