zibri
    Preparing search index...

    A service for handling websockets.

    interface WebsocketServiceInterface<Connection extends BaseWebsocketConnection> {
        attachTo: (app: ZibriApplication) => void | Promise<void>;
        disconnect: (connection: Connection) => void | Promise<void>;
        findConnectionById: (id: string) => Connection | Promise<Connection>;
        findConnectionByUserId: (
            userId: string,
        ) => Connection | Promise<Connection>;
        getConnections: () => Connection[] | Promise<Connection[]>;
        joinChannel: (
            connection: Connection,
            channelId: string,
        ) => void | Promise<void>;
        leaveChannel: (
            connection: Connection,
            channelId: string,
        ) => void | Promise<void>;
        registerController: (
            controllerClass: Newable<unknown>,
        ) => void | Promise<void>;
        send: <B extends boolean>(
            data: WebsocketSendData<Connection, B>,
        ) => WebsocketSendResult<B, Connection>;
        sendToAll: <B extends boolean>(
            data: WebsocketSendToAllData<B>,
        ) => WebsocketSendToMultipleResult<B, Connection>;
        sendToChannel: <B extends boolean>(
            data: WebsocketSendToChannelData<B>,
        ) => WebsocketSendToMultipleResult<B, Connection>;
    }

    Type Parameters

    Implemented by

    Index

    Properties

    attachTo: (app: ZibriApplication) => void | Promise<void>

    Attaches the service to the application.

    disconnect: (connection: Connection) => void | Promise<void>

    Disconnects the given connection.

    findConnectionById: (id: string) => Connection | Promise<Connection>

    Finds the websocket connection with the given id.

    findConnectionByUserId: (userId: string) => Connection | Promise<Connection>

    Finds the websocket connection with the given user id.

    getConnections: () => Connection[] | Promise<Connection[]>

    Gets all currently active connections.

    joinChannel: (connection: Connection, channelId: string) => void | Promise<void>

    Adds the given connection to the channel with the given id.

    leaveChannel: (
        connection: Connection,
        channelId: string,
    ) => void | Promise<void>

    Removes the given connection from the channel with the given id.

    registerController: (controllerClass: Newable<unknown>) => void | Promise<void>

    Registers a websocket controller that listens to events.

    send: <B extends boolean>(
        data: WebsocketSendData<Connection, B>,
    ) => WebsocketSendResult<B, Connection>

    Sends a message to a single connection.

    sendToAll: <B extends boolean>(
        data: WebsocketSendToAllData<B>,
    ) => WebsocketSendToMultipleResult<B, Connection>

    Sends a message to all connections.

    sendToChannel: <B extends boolean>(
        data: WebsocketSendToChannelData<B>,
    ) => WebsocketSendToMultipleResult<B, Connection>

    Sends a message to a single channel.