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
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
connection | readonly | RainwayConnection | The RainwayConnection from which the connection to this peer was established. |
dataChannels | readonly | ReadonlyMap<string, DataChannel> | A map from channel names (labels) to Data Channels opened between us and this peer. |
externalId | readonly | string | A string identifying this peer in your organization. (For example: the "username" of the peer.) |
id | readonly | PeerId | This peer's Rainway id. |
state | readonly | PeerState | The peer's network connectivity state. |
streams | readonly | ReadonlyMap<number, InboundStream> | A map from Stream IDs to active streams associated with this peer. |
Methods
Method | Modifiers | Description |
---|---|---|
close() | Disconnect from this peer. | |
createDataChannel(options) | Create a new data channel for exchanging application-level data with this peer. The returned If an error prevents the channel from being created or opened, the promise rejects with a 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 | |
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. |