diff --git a/docs/lwpCall.md b/docs/lwpCall.md index 4c4994c..ff28229 100644 --- a/docs/lwpCall.md +++ b/docs/lwpCall.md @@ -198,6 +198,17 @@ Returns: | ------------------------------------------------------------------------------------------- | ------------------------------------------------ | | string | User representation of the instance's remote URI | + +#### getCustomData() + +This returns a custom object for application usage + +Returns: + +| Type | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------ | +| object | Custom `data` object that is extracted from its associated [RTCSession data](https://jssip.net/documentation/3.4.x/api/session/#attribute_data) | + #### terminate() If the instance has a session, invokes the jssip terminate method described by diff --git a/docs/lwpUserAgent.md b/docs/lwpUserAgent.md index cd1fc97..e6cba5b 100644 --- a/docs/lwpUserAgent.md +++ b/docs/lwpUserAgent.md @@ -122,7 +122,9 @@ Updates the redial target. | anonymous | boolean | false | Whether the call should be done anonymously | | options | object | `{receive_video: false, anonymous: false}` | additional call options | | options.anonymous | boolean | false | Whether the call should be done anonymously | -| options.receive_video | boolean | false | Wheter the call should accept remote video stream | +| options.receive_video | boolean | false | Whether the call should accept remote video stream | +| options.secondary_call | boolean | false | Whether the call should not be promoted to primary when is created | +| options.custom_data | object | `{}` | Custom data that can be accessed in the created lwpCall instance by `call.getCustomData()` | Attempts to create a new call to target, or the redial target if non is provided as an argument. diff --git a/src/lwpCall.js b/src/lwpCall.js index 6a910ec..320160e 100644 --- a/src/lwpCall.js +++ b/src/lwpCall.js @@ -146,11 +146,18 @@ export default class { remoteURIUser() { const session = this._getSession(); - if (session) { + if (session && session._dialog._remote_uri) { return session._dialog._remote_uri.user; } } + getCustomData () { + const session = this._getSession(); + if (session) { + return session.data; + } + } + terminate() { if (this.hasSession()) { if (this.isEstablished()) { diff --git a/src/lwpCallList.js b/src/lwpCallList.js index 5a19baa..2537c68 100644 --- a/src/lwpCallList.js +++ b/src/lwpCallList.js @@ -33,8 +33,7 @@ export default class extends lwpRenderer { addCall(newCall) { const previousCall = this.getCall(); - - if (previousCall && !previousCall.isOnHold()) { + if ((previousCall && !previousCall.isOnHold()) || newCall.getCustomData().lwpSecondaryCall) { this._calls.push(newCall); this._emit("calls.added", this, newCall); } else { diff --git a/src/lwpUserAgent.js b/src/lwpUserAgent.js index 33c4d3a..428942d 100644 --- a/src/lwpUserAgent.js +++ b/src/lwpUserAgent.js @@ -229,7 +229,12 @@ export default class extends lwpRenderer { defaultOptions.rtcOfferConstraints = { offerToReceiveVideo: options.receive_video || false }; - defaultOptions.anonymous = options.anonymous || false + defaultOptions.anonymous = options.anonymous || false; + defaultOptions.data = { + lwpSecondaryCall: options.secondary_call || false, + ...(options.custom_data || {}), + ...defaultOptions.data + } } const mediaDevices = this._libwebphone.getMediaDevices(); const callList = this._libwebphone.getCallList();