mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
59023657a02cf78f90522e0d7797749707ed5ed2
Syntax:
```ts
interface ServerToClientEvents {
"my-event": (a: number, b: string, c: number[]) => void;
}
interface ClientToServerEvents {
hello: (message: string) => void;
}
const socket: Socket<ServerToClientEvents, ClientToServerEvents> = io();
socket.emit("hello", "world");
socket.on("my-event", (a, b, c) => {
// ...
});
```
The events are not typed by default (inferred as any), so this change
is backward compatible.
Related: https://github.com/socketio/socket.io/issues/3742
socket.io-client
Documentation
Please see the documentation here.
The source code of the website can be found here. Contributions are welcome!
Debug / logging
In order to see all the client debug output, run the following command on the browser console – including the desired scope – and reload your app page:
localStorage.debug = '*';
And then, filter by the scopes you're interested in. See also: https://socket.io/docs/v3/logging-and-debugging/
License
Languages
TypeScript
63.8%
JavaScript
36%