Base class for grouping socket events. The event can be called from the client [lowerCasedClassName].[method]. All underscored methods and methods of the base class are ignored in the event list.

class User extends SocketClass {
// This method will be accessible from the client as user.get event.
async get(socket, data) {
return { id: 1, name: 'Baf Lek' };
}
}

Type Parameters

Constructors

Properties

broadcast: ((filter?: ((socket: Socket<Session<any>>) => boolean), event?: string, includeSelf?: boolean) => MethodDecorator)

Decorator for the methods to broadcast the response after the execution.

notSocketMethod: MethodDecorator

Decorator for methods to be not registered as socket methods. They cannot be called from socket.

requireAuth: MethodDecorator

Decorator for the methods to check the logged user before the execution.

Methods

  • Broadcasts the event and data to the clients except the sender.

    Type Parameters

    • T = any

    Parameters

    • event: string

      Event name.

    • data: T

      Data to broadcast.

    Returns void

    T Type of the data.

  • Broadcasts the event and data to the clients.

    Type Parameters

    • T = any

    Parameters

    • event: string

      Event name.

    • data: T

      Data to broadcast.

    • includeSelf: boolean

      Indicates if the broadcast should include the sender.

    Returns void

    T Type of the data.

  • Broadcasts the event and data to the clients passed the filter.

    Type Parameters

    • T = any

    Parameters

    • event: string

      Event name.

    • data: T

      Data to broadcast.

    • includeSelf: boolean

      Indicates if the broadcast should include the sender.

    • filter: ((socket: Socket<Session<any>>) => boolean)

      Function to filter receivers of the broadcast.

        • (socket): boolean
        • Parameters

          Returns boolean

    Returns void

    T Type of the data.