lundi 2 mars 2015

Simple NodeJS socketIO server throws error

Trying to debug this simple NodeJS socketIO server. I keep getting the following error message on launch. I can't see anything wrong with the code. Can anyone help?


TypeError: listener must be a function at TypeError () at Namespace.EventEmitter.addListener (events.js:130:11) at Server.(anonymous function) [as on] (/Users/foo/bin/node_modules/http://ift.tt/1vTpwtS) at Object. (/Users/foo/bin/foo.js:11:4) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16)



var app = require("express");
var server = require("http").Server(app);
var io = require("socket.io")(server);

io.on("connection", handleClient);


var handleClient = function (socket) {
// we've got a client connection

socket.emit("tweet", {user: "nodesource", text: "Hello, world!"});
};

app.listen(8080);

Aucun commentaire:

Enregistrer un commentaire