import { Socket, Server } from "socket.io"; export function setupSocketIO(io: Server) { io.on("connection", (socket: Socket) => { console.log(`socket ${socket.id} connected`); socket.emit("hello", "world"); socket.on("disconnect", (reason) => { console.log(`socket ${socket.id} disconnected due to ${reason}`); }); // 可在此添加更多socket事件处理 }); }