mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-10 23:48:02 -05:00
"connect" and "connection" have the same meaning, but "connection" is the preferred version.
17 lines
301 B
JavaScript
17 lines
301 B
JavaScript
import { Server } from "socket.io";
|
|
|
|
const io = new Server(8080);
|
|
|
|
io.on("connection", (socket) => {
|
|
console.log(`connect ${socket.id}`);
|
|
|
|
socket.on("ping", (cb) => {
|
|
console.log("ping");
|
|
cb();
|
|
});
|
|
|
|
socket.on("disconnect", () => {
|
|
console.log(`disconnect ${socket.id}`);
|
|
});
|
|
});
|