Make an attended transfer with SIP.js

3.9k Views Asked by At

Good morning, I need to make attended transfers with SIP.js. Anyone succeded in this task? I can only make blind transfers right now, i found an article that reports that in version 0.7.x there is support for attended transfer trough replace command.

https://www.onsip.com/blog/sipjs-070-adds-fixes-and-support-for-attended-transfer-recommended-upgrade

2

There are 2 best solutions below

0
On

I solved this for audio this manner

    sessionOne.hold();//already exists previously


    var uri = phone + '@' + sip_server;
    var options = {
       media: {
           constraints: {
               audio: true,
               video: false
           },
           render: {
               remote: document.getElementById('audio-output')
           },
           stream: mediaStream
       },
       extraHeaders: [...],
       inviteWithoutSdp: true,
       rel100: SIP.C.supported.SUPPORTED,
       activeAfterTransfer: false //die when the transfer is completed
   };

   sessionTwo = userAgent.invite(uri, options);
   //if yo want handle the transfer at the application level, then implements the handler events as on('refer', function(request) {}) for the session object
   ...
   sessionOne.refer(sessionTwo);//session two already must is accepted (sip server)
0
On

Maybe too late, but I write answer for future. I made it in this steps:

  • saved current session in other variable, for example var holded_session = session;
  • call in current session hold, session.hold()
  • make new call ua.invite()
  • make transfer session.refer(holded_session)

Functions hold() and unhold() are not documented in documentation, but when you output session into console, you will see its in there.