Skip to content

Commit

Permalink
feat: add support for creating an rtcdatachannel (#15)
Browse files Browse the repository at this point in the history
* feat: add support for creating an rtcdatachannel

* docs: fix docs
  • Loading branch information
bbaldino authored and GitHub Enterprise committed Sep 27, 2021
1 parent 4fec16f commit 66d88b2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/peer-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ enum MediaStreamTrackKind {
Video = 'video',
}

type RTCDataChannelOptions = {
ordered?: boolean;
maxPacketLifeTime?: number;
maxRetransmits?: number;
protocol?: string;
negotiated?: boolean;
id?: number;
};

/**
* Manages a single RTCPeerConnection with the server.
*/
Expand Down Expand Up @@ -83,6 +92,17 @@ class PeerConnection extends EventEmitter {
this.pc.removeTrack(sender);
}

/**
* Creates a new data channel linked with the remote peer.
*
* @param label - A human-readable name for the channel. May not be longer than 65,535 bytes.
* @param options - An object providing configuration options for the data channel.
* @returns An RTCDataChannel object.
*/
createDataChannel(label: string, options: RTCDataChannelOptions): RTCDataChannel {
return this.pc.createDataChannel(label, options);
}

/**
* Creates an SDP answer to an offer received from a remote peer during the offer/answer
* negotiation of a WebRTC connection.
Expand Down

0 comments on commit 66d88b2

Please sign in to comment.