Class Channel

A class representing a Channel for the Bagman client.

Hierarchy

  • Channel

Constructors

  • Creates a new instance of Channel.

    Parameters

    • socket: ClientSocket

      The socket.io client socket to use for communication.

    • channel: string

      The name of the channel to subscribe to.

    Returns Channel

Properties

channel: string

The name of the channel to subscribe to.

deactivated: boolean = false

Param

Whether this channel is deactivated.

socket: ClientSocket

The socket.io client socket to use for communication.

Methods

  • Registers a callback function to be executed when the specified event is emitted.

    Returns

    void

    Type Parameters

    • T extends any[]

      The type of data to be passed as arguments to the callback function.

    Parameters

    • event: string

      The name of the event to listen for.

    • cb: ((...args: T) => void | Promise<void>)

      The callback function to be executed when the specified event is emitted.

        • (...args: T): void | Promise<void>
        • Parameters

          • Rest ...args: T

          Returns void | Promise<void>

    Returns void

  • Fetch Presences of the current channel.

    Returns

    • list of presences that's within this channel

    Type Parameters

    • T

      the type of presence that you expected to receive

    Returns Promise<Presence<T>[]>

  • Publishes an event to the channel.

    Returns

    Promise - A promise that resolves if the event was successfully published, and rejects if there was an error.

    Type Parameters

    • Data extends unknown

      The type of data to be passed along with the event.

    Parameters

    • event: string

      The name of the event to be published.

    • data: Data

      The data to be passed along with the event.

    Returns Promise<void>

  • Unsubscribes from the channel.

    Returns

    Promise - A promise that resolves if the unsubscribe was successful, and rejects if there was an error.

    Returns Promise<void>

Generated using TypeDoc