增加socketio server 支持
This commit is contained in:
15
server/routes_socketio.ts
Normal file
15
server/routes_socketio.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
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事件处理
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user