Web SDK - RainwayPeer

Home > rainway-sdk > RainwayPeer

RainwayPeer class

An object representing a remote Rainway peer.

Acquire one of these objects from RainwayRuntime.connect(). Then ask for a stream with RainwayPeer.requestStream().

For more info, see: https://docs.rainway.com/tutorial/exchanging-messages https://docs.rainway.com/tutorial/streaming


export declare class RainwayPeer 


The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the RainwayPeer class.


externalIdstringA string identifying this peer in your organization. (For example: the "username" of the peer.)
peerIdPeerIdThis peer's Rainway peerId.
readyToStreamPromise<boolean>A promise that resolves as soon as the initial negotiation of capabilities has finished.If it resolves to true, this peer is now ready to stream media to us. If it resolves to false, it means this peer can't stream media at all.Calling requestStream awaits this automatically, so it's never strictly necessary to call this, but it may be useful to know when a peer is "all set" (perhaps to update the UI).
stateRainwayPeerStateThe peer's network connectivity state.
streamRainwayStream | undefinedThe active stream associated with this peer.
streamsReadonlyMap<number, RainwayStream>The active streams associated with this peer.


createDataChannel(channelName, mode)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
disconnect()Disconnect from this peer.
requestStream(inputLevel)Request a Rainway stream from this peer.
send(channelName, data)Send a message to this peer.See: https://docs.rainway.com/docs/data-channels