I'm trying to implement the node server from this guide: http://java.dzone.com/articles/getting-started-socketio-and . However, I've run into an issue. When I do node file.js, it spits out that Object # has no method readFilesync. I'm confused, because it's the same as in the guide and there is in fact a readFilesync method.
Here's the code:
var fs = require('fs'),
http = require('http'),
socketio = require('socket.io');
var server = http.createServer(function(req, res) {
res.writeHead(200, { 'Content-type': 'text/html' });
res.end(fs.readFilesync(__dirname + '/home/name/projects/proj/proj/templates/chat/chat.html'));
}).listen(9001, function() {
console.log('Listening at: http://name.site.com:9001');
});
socketio.listen(server).on('connection', function (socket) {
socket.on('message', function (msg) {
console.log('Message Received: ', msg);
socket.broadcast.emit('message', msg);
});
});
Just a mis-capitalization maybe? It's readFileSync, not readFilesync. (The article you linked got it right, too).