This module is an extension of socket.io, so the internal behavior (methods, properties, ...) is the same
This library allows you to use TypeScript decorators on socket.io, it simplifies your code and improves the readability!
Version 16.6.0 or newer of Node.js is required
npm install socket.io @discordx/socket.io
yarn add socket.io @discordx/socket.io
do not forget to wrap each class with
@Ws()
import { Guard, Next, On, Once, Server, Ws } from "@discordx/socket.io";
import { Socket } from "socket.io";
@Ws()
class Example {
@On("connection")
@Guard(([]: [Socket], server: Server, socket: unknown, next: Next) => {
console.log("I am mdw");
return next();
})
on(): void {
console.log("I am @onx");
}
@On("disconnect")
disconnect(): void {
console.log("I am disconnect");
}
@Once("connection")
once(): void {
console.log("I am @Once");
}
}