0

I have implemented SIP.js for my vue call app to make and receive calls. the transfer does not work as expected. this is my current code:

const transferCall = async (phoneNumber) => {
if (dialerStore.callStatus.callTransferStatus) {
    // meaning one call transfer is still going on
    return;
}

const validatedPhone = validateMobile(phoneNumber);
const simpleUser = dialerStore.getSimpleUser();
const numberId = dialerStore.callStatus.numberId;
const currentSessionId = simpleUser.session._id;
const currentOngoingSession = simpleUser.sessionManager.userAgent._sessions[currentSessionId];
const { domain } = dialerStore.sipCredentials[numberId];

await simpleUser.sessionManager.hold(currentOngoingSession);

await simpleUser.sessionManager.call(
    `sip:${validatedPhone}@${domain}`,
    {},
    {
        requestDelegate: {
            onProgress() {
                dialerStore.callStatus.callTransferStatus = 'Transferring..';
            },
            onAccept() {
                simpleUser.hold();
                currentOngoingSession.refer(simpleUser.session, {
                    requestDelegate: {
                        onAccept(response) {
                            simpleUser.unhold(); //unhold user
                            dialerStore.callStatus.callTransferStatus = `Transferred to ${validatedPhone}`;
                            currentOngoingSession.bye();
                            console.log('user available');
                        },
                        onReject() {
                            simpleUser.unhold(); //unhold user
                            simpleUser.session = currentOngoingSession;
                            dialerStore.callStatus.callTransferStatus = 'NOt available';
                            console.log('user unavailable');
                        }
                    }
                });
            },
            onReject() {
                simpleUser.session = currentOngoingSession;
                dialerStore.callStatus.callTransferStatus = '';
                simpleUser.unhold(); //unhold user
                console.log('user unavailable-1');
            }
        }
    }
);

};

the trasnfer works but if i reject the transfer, the call ends which should not be. i want to remove the caller from hold and be able to continue if the transfer fails. can anyone advise?

0 Answers0