📜  socket io 脚本 - Html 代码示例

📅  最后修改于: 2022-03-11 14:53:22.105000             🧑  作者: Mango

代码示例2
const express = require('express');const app = express();const http = require('http');const server = http.createServer(app);const { Server } = require("socket.io");const io = new Server(server);app.get('/', (req, res) => {  res.sendFile(__dirname + '/index.html');});io.on('connection', (socket) => {  console.log('a user connected');});server.listen(3000, () => {  console.log('listening on *:3000');});