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); this.emit(SipConstants.UA_STOP);
} }
call(number: string): void { call(number: string, customHeaders: string[] = []): void {
let normalizedNumber: string = normalizeNumber(number); let normalizedNumber: string = normalizeNumber(number);
this.#ua.call(normalizedNumber, { this.#ua.call(normalizedNumber, {
extraHeaders: [`X-Original-Number:${number}`], extraHeaders: [`X-Original-Number:${number}`].concat(customHeaders),
mediaConstraints: { audio: true, video: false }, mediaConstraints: { audio: true, video: false },
pcConfig: this.#rtcConfig, pcConfig: this.#rtcConfig,
}); });

View File

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