比如说这一段: var app = require(‘http’).createServer(handler), io = require(‘socket.io’).listen(app), fs = require(‘fs’) app.listen(8080);
console.log(__dirname + ‘/index.html’);
function handler(req, res) { fs.readFile(__dirname + '/index.html’, function (err, data) { if (err) { res.writeHead(500); return res.end(‘Error loading index.html’); } res.writeHead(200, { 'Content-Type’: ‘text/html’ }); res.end(data); }); }
io.sockets.on('connection’, function (socket) { io.sockets.emit('link’, ‘欢迎加入’);
socket.on('chart', function (data) {
io.sockets.emit('chart', data);
})
});
怎么把他变成express的