Created
July 28, 2017 13:59
-
-
Save masterk63/7c596c392c0742f8571f686a1a80c0b6 to your computer and use it in GitHub Desktop.
Web Socket simple node
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
//npm install socket.io --save | |
// socket.js | |
var socket = require('socket.io'), | |
http = require('http'), | |
server = http.createServer(), | |
socket = socket.listen(server); | |
socket.on('connection', function(connection) { | |
console.log('User Connected'); | |
connection.on('message', function(msg){ | |
socket.emit('message', msg); | |
}); | |
}); | |
server.listen(3000, function(){ | |
console.log('Server started'); | |
}); | |
// node socket.js para correr la aplicacion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment