TODO: Introduction + links to other sections.
All interaction from javascript to pjsip module is asynchronous. So for each action, promise will be returned.
TODO: Description
TODO: Description
TODO: Description
To be able to make a call first of all you should createAccount, and pass account instance into Endpoint.makeCall function. This function will return a promise that will be resolved when PjSIP initializes the call.
let options = {
headers: {
"P-Assserted-Identity": "Header example",
"X-UA": "React native"
}
}
let call = await endpoint.makeCall(account, destination, options);
call.getId() // Use this id to detect changes and make actions
endpoint.addListener("call_changed", (newCall) => {
if (call.getId() === newCall.getId()) {
// Our call changed, do smth.
}
}
endpoint.addListener("call_terminated", (newCall) => {
if (call.getId() === newCall.getId()) {
// Our call terminated
}
}
After answer there will be event "call_changed" that reflect the changes. If there is already active call, it will be placed on hold (so expect "call_changed" event)
let options = {};
let call = ...;
let promise = endpoint.answerCall(call, options);
promise.then(() => {
// Answer complete, expect that "call_changed" will be fired.
}));
promise.catch(() => {
// Answer failed, show error
});
Use this function when you have active call, and Decline for unanswered incoming calls. After successul hangup, Endpoint should fire "call_terminated" event, use it to how final call duration and status.
let options = {};
let call = ...;
await endpoint.hangupCall(call, options);
Use this function when you have unanswered incoming call. After successul decline, Endpoint should fire "call_terminated" event.
let options = {};
let call = ...;
await endpoint.declineCall(call, options);
TODO: Description
After successul hold/unhold, Endpoint should fire "call_changed" event, where isHeld
should be false or true.
let options = {};
let call = ...;
await endpoint.holdCall(call, options);
await endpoint.unholdCall(call, options);
TODO: Description
let options = {};
let call = ...;
await endpoint.xferCall(call, destination, options);
TODO: Description
let options = {};
let call = ...;
let key = "3";
await endpoint.dtmfCall(call, key, options);