Jssip library.How to get updated session after successfullly call transfer

177 views Asked by At

I use the jssip library to organize telephony in CRM. In order to connect line A and B in the jssip library, the Sip.RTP Session class has a refer method that normally works out and connects both lines. If I am not the initiator of the connection of two lines, that is, I am on line 'A', after I am connected to line 'B', I expect to hear the subscriber of line 'B', at the same time I need to get an updated session in order to display new data in the widget showing information about the current call, that is, the data of subscriber 'B. This is actually the question of how, after connecting my line with line B, to get a session of subscriber B, for the correct rendering of the widget of the current call. After researching the official jsp documentation, the only thing I found was the replaces event, fired when an out of dialog INVITE is received pointing to this RTCSession through the Replaces header field. The object of this event has an accept method, which I thought would trigger the newRTCSession event, and I would be able to get an updated session. But this event is not triggered if I am not the initiator of the connection of two lines

Below is a code snippet when I am the initiator of the connection of two lines

 incomingSession.refer(outComingSession.remote_identity.uri, {
      replaces: outComingSession,
      eventHandlers: {
        accepted: () => {
          incomingSession.data = { successTwoLinesConnection: true }
          outComingSession.data = { successTwoLinesConnection: true }
          incomingSession.terminate()
          outComingSession.terminate()
          sendPhonerSecondLineEvents('success')
        },
        failed: (e: any) => {
          console.log('two lines failed', 'error', e)
        },                                  
      },
    })

below is a code snippet where I hang event handlers on the session class

    useEffect(() => {sessions.forEach(session = 
 session.on('replaces', (e: ReferEvent) => {
        // don`t fire if a`m not a initiator of the connection
        console.log('replacesEvent', e)
        e.accept()
      })
 session.on('update', (e) => {
        console.log('update', e)
      })
    )},[sessions.length, isSecondLineOutcomingCallConnecting])
0

There are 0 answers