mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Typed events in Socket.IO 4.0 remove the need for writing type annotations in callbacks of reserved events.
17 lines
320 B
TypeScript
17 lines
320 B
TypeScript
import { Server } from "socket.io";
|
|
|
|
const io = new Server(8080);
|
|
|
|
io.on("connect", (socket) => {
|
|
console.log(`connect ${socket.id}`);
|
|
|
|
socket.on("ping", (cb) => {
|
|
console.log("ping");
|
|
cb();
|
|
});
|
|
|
|
socket.on("disconnect", () => {
|
|
console.log(`disconnect ${socket.id}`);
|
|
});
|
|
});
|