-
-
Save alejandro/525f55a7a2c457af2981 to your computer and use it in GitHub Desktop.
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
# if i don't parseInt the app_port var i get this | |
> app_port=2131 node server | |
node.js:201 | |
throw e; // process.nextTick error, or 'error' event on first tick | |
^ | |
TypeError: Object 2131 has no method 'on' | |
at new Manager (/home/alejandromg/9539-92fd447a71e931bda296344ae90b9f48/node_modules/socket.io/lib/manager.js:101:10) | |
at Object.listen (/home/alejandromg/9539-92fd447a71e931bda296344ae90b9f48/node_modules/socket.io/lib/socket.io.js:71:10) | |
at Object.<anonymous> (/home/alejandromg/9539-92fd447a71e931bda296344ae90b9f48/server.js:4:31) | |
at Module._compile (module.js:441:26) | |
at Object..js (module.js:459:10) | |
at Module.load (module.js:348:31) | |
at Function._load (module.js:308:12) | |
at Array.0 (module.js:479:10) | |
at EventEmitter._tickCallback (node.js:192:40) |
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
// this works | |
var PORT = parseInt(process.env['app_port'],10) || 3000; | |
var io = require("socket.io").listen( PORT, function(){ | |
io.sockets.on("connection",arrancar); | |
function arrancar(msg){ | |
msg.on("nuevoMensaje",emitir); | |
} | |
function emitir(data){ | |
io.sockets.emit("mensaje",data); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment