Web SDK - Peer

Home > @rainway/web > Peer

Peer class

An object representing a remote Rainway peer.

Acquire one of these objects from RainwayConnection.connect(). Then ask for a stream with Peer.createStream().

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


export declare class Peer extends EventEmitter<PeerEvents> 

Extends: EventEmitter<PeerEvents


connectionreadonlyRainwayConnectionThe RainwayConnection from which the connection to this peer was established.
dataChannelsreadonlyReadonlyMap<string, DataChannel>A map from channel names (labels) to Data Channels opened between us and this peer.
externalIdreadonlystringA string identifying this peer in your organization. (For example: the "username" of the peer.)
idreadonlyPeerIdThis peer's Rainway id.
statereadonlyPeerStateThe peer's network connectivity state.
streamsreadonlyReadonlyMap<number, InboundStream>A map from Stream IDs to active streams associated with this peer.


close()Disconnect from this peer.

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 RainwayConnection.connect, and not elsewhere.

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

createStream(options)Request a stream from this peer.
forceStreamAnnouncements()Forces the remote peer to (re)announce all streams that are currently active. Results in the stream-announcement event being raised for each active stream, if any.