Function useDataChannel

  • The useDataChannel hook returns the ability to send and receive messages. By optionally passing a topic, you can narrow down which messages are returned in the messages array.

    Remarks

    There is only one data channel. Passing a topic does not open a new data channel. It is only used to filter out messages with no or a different topic.

    Example

    // Send messages to all participants via the 'chat' topic.
    const { message, send } = useDataChannel('chat');

    Type Parameters

    Type Parameters

    • T extends string

    Parameters

    Returns UseDataChannelReturnType<T>

  • The useDataChannel hook returns the ability to send and receive messages.

    Remarks

    There is only one data channel. Passing a topic does not open a new data channel. It is only used to filter out messages with no or a different topic.

    Example

    // Send messages to all participants
    const { message, send } = useDataChannel(callback);

    Parameters

    Returns UseDataChannelReturnType

Generated using TypeDoc