HomeGuidesAPI Reference
HubBlogChangelogSupport ForumLog In
API Reference

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

Signature:

export declare class Peer extends EventEmitter<PeerEvents> 

Extends: EventEmitter<PeerEvents>

Remarks

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

Properties

PropertyModifiersTypeDescription
dataChannelsReadonlyMap<string, DataChannel>A map from channel names (labels) to Data Channels opened between us and this peer.
externalIdstringA string identifying this peer in your organization. (For example: the "username" of the peer.)
idPeerIdThis peer's Rainway id.
statePeerStateThe peer's network connectivity state.
streamsReadonlyMap<number, InboundStream>A map from Stream IDs to active streams associated with this peer.

Methods

MethodModifiersDescription
close()Disconnect from this peer.
createDataChannel(options)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.