var app=require('express')();
var http=require('http').Server(app);
var players=[];
var io=require('socket.io')(http);
const port=8000;
app.get('/', (req, res) => {
res.sendFile(__dirname+ '/index.html');
});
io.on('connection',(socket) => {
console.log(socket,'connected!');
socket.on('disconnect',() => {
console.log(socket,'disconnected!');
});
});
http.listen(port, () => {
console.log(`listening on port: ${port}`);
});
我试图让服务器用套接字和节点来学习快递......但是当我运行这个程序时,console.log()没有工作,并且在cmd中没有出现什么都没有。