Skip to content

Commit

Permalink
[FEATURE]: RTCPeerConnection configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasszoke committed Apr 8, 2019
1 parent e3f875d commit cbd95b0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,34 @@ WebRTC wrapper with built-in signaling for React and Vue.

**Important:** you have to set up all of the callback functions above.

**RTCPeerConnection configuration** (optional)

Add the following properties to the above `config` object.

`connectionConfig`: set the STUN/TURN servers and other connection options, for more information check the [RTCConfiguration dictionary](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection#RTCConfiguration_dictionary).
Default value:

{
iceServers: [
{
url: 'stun:stun.l.google.com:19302'
}
]
}

`optionalConfig`: set the optional connection configurations. Default value:

{
optional: [
{
DtlsSrtpKeyAgreement: true
},
{
RtpDataChannels: false
}
]
}

### Create an instance

rtc = new NeatRTC(config, sendSignalingMessage);
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const NeatRTC = (config, sendCallback) => {

const DEVELOPMENT_MODE = config.devMode || false
const DATACHANNEL_CONFIG = config.datachannels || []
const CONNECTION_CONFIG = config.connectionConfig || null
const OPTIONAL_CONFIG = config.optionalConfig || null
let peerConnection = []
let datachannelList = []
let streamLocal = null
Expand Down Expand Up @@ -52,14 +54,14 @@ const NeatRTC = (config, sendCallback) => {
* @param {string} connectionType
*/
const initConnection = (connectionType) => {
const CONFIGURATION = {
const CONFIGURATION = CONNECTION_CONFIG || {
iceServers: [
{
url: 'stun:stun.l.google.com:19302'
}
]
}
const OPTIONAL = {
const OPTIONAL = OPTIONAL_CONFIG || {
optional: [
{
DtlsSrtpKeyAgreement: true
Expand Down

0 comments on commit cbd95b0

Please sign in to comment.