Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWP-2: Add secondary_call and custom_data options in call method #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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