Skip to content

Commit

Permalink
LWP-2: Add secondary_call and custom_data options in call method
Browse files Browse the repository at this point in the history
  • Loading branch information
Irvandoval committed Apr 8, 2024
1 parent fa35a7c commit 1edc9f9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
11 changes: 11 additions & 0 deletions docs/lwpCall.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion docs/lwpUserAgent.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion src/lwpCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
3 changes: 1 addition & 2 deletions src/lwpCallList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion src/lwpUserAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1edc9f9

Please sign in to comment.