Web SDK - RainwayPeer.createDataChannel()

Home > rainway-sdk > RainwayPeer > createDataChannel

RainwayPeer.createDataChannel() method

Create a new data channel for exchanging application-level data with this peer. The returned Promise resolves once the new data channel has been opened.

If an error prevents the channel from being created or opened, the promise rejects with a RainwayError.

As a rule, the party that requested the peer-to-peer connection should create the data channels. This means you should call this function on a RainwayPeer you get from RainwayRuntime.connect, and not elsewhere.

See: https://docs.rainway.com/docs/data-channels

Signature:

createDataChannel(channelName: string, mode: RainwayChannelMode): Promise<void>;

Parameters

ParameterTypeDescription
channelNamestringThe name of the Data Channel to create.
modeRainwayChannelModeA mode (reliable or unreliable) for the new channel.

Returns:

Promise<void>

Whether the channel was successfully created and opened.