This commit is contained in:
Quan HL
2023-10-23 11:11:57 +07:00
parent 46149878a5
commit 0f494bfaa3
2 changed files with 11 additions and 8 deletions

View File

@@ -126,10 +126,10 @@ export default class SipUA extends events.EventEmitter {
this.emit(SipConstants.UA_STOP);
}
call(number: string): void {
call(number: string, customHeaders: string[] = []): void {
let normalizedNumber: string = normalizeNumber(number);
this.#ua.call(normalizedNumber, {
extraHeaders: [`X-Original-Number:${number}`],
extraHeaders: [`X-Original-Number:${number}`].concat(customHeaders),
mediaConstraints: { audio: true, video: false },
pcConfig: this.#rtcConfig,
});

View File

@@ -270,7 +270,7 @@ export const Phone = ({
makeOutboundCall(inputNumber);
};
const makeOutboundCall = (number: string) => {
const makeOutboundCall = (number: string, customHeaders: string[] = []) => {
if (sipUA.current && number) {
setIsCallButtonLoading(true);
setCallStatus(SipConstants.SESSION_RINGING);
@@ -282,7 +282,7 @@ export const Phone = ({
duration: "0",
callSid: uuidv4(),
});
sipUA.current.call(number);
sipUA.current.call(number, customHeaders);
}
};
@@ -449,7 +449,7 @@ export const Phone = ({
resolve(
json.map((q) => ({
name: q,
value: `queue-${q}`,
value: q,
}))
);
})
@@ -464,8 +464,11 @@ export const Phone = ({
<IconButtonMenu
icon={<List />}
onClick={(value) => {
setInputNumber(value);
makeOutboundCall(value);
const calledAppId = `app-${value}`;
setInputNumber(calledAppId);
makeOutboundCall(calledAppId, [
`X-Application-Sid: ${value}`,
]);
}}
onOpen={() => {
return new Promise<IconButtonMenuItems[]>(
@@ -475,7 +478,7 @@ export const Phone = ({
resolve(
json.map((a) => ({
name: a.name,
value: `app-${a.application_sid}`,
value: a.application_sid,
}))
);
})