Created
July 28, 2017 14:20
-
-
Save ingeit/abaac06a764e4dba4e021f752093756b to your computer and use it in GitHub Desktop.
Web Socket simple node
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
//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