var express = require('express');
var router = express.Router();
/* Socket.io */
var server = require("http").Server(express);
var io = require("socket.io")(server);
server.listen(5000);
io.on('connection', function(client) {
client.on('score_'+userId, function(data) {
});
});
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
module.exports = router;
socket.io块导致错误,但我不知道为什么。代码对我来说很好。
答案 0 :(得分:1)
使用var server = require("http").createServer(express());
代替var server = require("http").Server(express);