skip to Main Content

I’m using Azure Communication Service to create video calls between 2 people (person 1 and person 2).

Person 1 logs in and waits for person 2 to log in.
When person 2 connects person 1 is notified by the "incomingCall" function

callAgent.on('incomingCall', async (args) => {
    console.log("-------- ON incomingCall ------------");
    try {
            incomingCall = args.incomingCall;
            acceptCallPop.style.display = "block";
            ring();
    } catch (error) {
            console.error("incomingCall ERROR");
            console.error(error);
    }
});

Person 1 can therefore accept the call with the "acceptCall" button.
But if person 1 takes too long to accept (around 30s), the call is destroyed and if person 1 clicks on "acceptCall" there is an error.

I manage to activate a function for person 2 who can therefore know that the call is destroyed but I cannot find how to make person 1 aware when the call is destroyed.

How can person 1 know that the call is destroyed in real time ?

2

Answers


  1. Chosen as BEST ANSWER

    Thanks to the link in your answer I found this which allows you to know if the call is failed:

    incomingCall.on('callEnded', args => {
                    console.log("incomingCall END");
                    console.log(args.callEndReason);
                    resetIncomingCall();
                });
    

    But I have another problem, if the 2 people connect at the same time, they both receive a call activating the incomingCall function. Let's imagine that person 2 answers, the call goes through to both people but since person 1 did not really respond to their incomingCall, the call disconnects after 30 seconds.

    Is it possible to destroy incomingCall when the call is started?


  2. For voice and video calling, access tokens are typically used to authenticate users and enable them to make calls. These tokens are issued for a limited timeframe (30 seconds in this case) and have a limit on the number of requests (1000 for issuing access tokens). When integrating voice and video calling features into your application, managing user identities and their associated access tokens within these limits is necessary, as stated in this document.

    Identity:

    enter image description here

    To handle the scenario where Person 1 needs to know if the call is destroyed in real time, event handling in Azure Communication Services can be utilized.
    -Code was taken from git

    call.on('stateChanged', async () => {
        console.log(`Call state changed: ${call.state}`);
        if (call.state === 'Disconnected') {
            // Call has been terminated
            console.log('Call has been terminated');
            // Send notification to person 1
            sendCallTerminationNotification();
        }
    });
    
    function sendCallTerminationNotification() {
        // Update UI
        console.log('Sending call termination notification to Person 1');
    }
    

    Alternatively, listen for the callEnded event on the Call object, as shown in this doc.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search