Skip to content

Commit

Permalink
added the ability to send custom headers on INVITE and update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anderson committed Jan 12, 2021
1 parent 60c9aff commit 8fc9aa6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
8 changes: 7 additions & 1 deletion docs/lwpUserAgent.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ Returns:

Updates the redial target.

#### call(target)
#### call(target, custom_headers, anonymous)

| Name | Type | Default | Description |
| ------ | ------ | ------- | --------------------------- |
| target | string | | The target for the new call |
| custom_headers | array | [] | A list of strings to add to the INVITE |
| anonymous | boolean | false | Whether the call should be done anonymously |

Attempts to create a new call to target, or the redial target if non is provided
as an argument.
Expand All @@ -128,6 +130,9 @@ streams, otherwise it will be left up to jssip internals.
Additionally, if lwpCallList is not available this will terminate any active
calls first ensuring only one call is active at a time.

If custom_headers are provided they will be merged with any configured headers. The
format of each string should be the full, valid SIP header. For example: "X-Foo: bar"

#### hangupAll()

Terminates all active calls for this user agent.
Expand Down Expand Up @@ -184,6 +189,7 @@ Re-paint / update all render targets.
| user_agent.register_expires | integer | 300 | From jssip documentation "Registration expiry time (in seconds) (Integer). " |
| user_agent.user_agent | string | 2600Hz libwebphone 2.x | From jssip documentation "User-Agent header field value (String) present in SIP messages." |
| user_agent.redial | string | \*97 | The initial value for the redial target |
| user_agent.custom_headers.establish_call | array | [] | A list of strings to add to every INVITE when establishing a call target |
| debug | boolean | false | The inital value for the debugging option |
| renderTargets | array | [] | See [lwpRenderer](lwpRenderer.md) |

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
"detectrtc": "^1.3.9",
"eventemitter2": "^6.2.1",
"i18next": "^19.0.1",
"jssip": "^3.3.11",
"jssip": "^3.7.0",
"lodash": "^4.17.15",
"media-device-id": "^1.0.1",
"mustache": "^3.1.0",
"pretty-ms": "^7.0.0",
"webrtc-adapter": "^7.3.0"
},
"devDependencies": {
"eslint": "^7.0.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.11.0",
"eslint": "^7.17.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.1",
"webpack-merge": "^4.2.2"
}
}
13 changes: 10 additions & 3 deletions src/lwpUserAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,12 @@ export default class extends lwpRenderer {
this._emit("redial.update", this, this._redialTarget);
}

call(target = null) {
let options = { data: { lwpStreamId: lwpUtils.uuid() } };
call(target = null, custom_headers = [], anonymous = false) {
let options = {
data: { lwpStreamId: lwpUtils.uuid() },
extraHeaders: [...custom_headers, ...this._config.custom_headers.establish_call],
anonymous: anonymous
};
const mediaDevices = this._libwebphone.getMediaDevices();
const callList = this._libwebphone.getCallList();

Expand Down Expand Up @@ -314,7 +318,10 @@ export default class extends lwpRenderer {
register: true,
register_expires: 300,
user_agent: "2600Hz libwebphone 2.x",
redial: "*97",
redial: "*97"
},
custom_headers: {
establish_call: []
},
debug: false,
};
Expand Down

0 comments on commit 8fc9aa6

Please sign in to comment.