Creating a button to gather information from JsSip

74 Views Asked by At

How can I create a button that will gather information from JsSip? I need a button that will gather information like : call quality, delay,jitter and other information from two agent that will call each other.

How can we do it using javascript?

I tried using an index.html script but didn't worked to me.

2

There are 2 best solutions below

1
cyberlord peace On
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Call Information</title>
  <script src="path/to/jsSIP.js"></script>
</head>
<body>
  <button id="gatherInfoBtn">Gather Call Information</button>
  <script>
    document.addEventListener('DOMContentLoaded', () => {
      const gatherInfoBtn = document.getElementById('gatherInfoBtn');

      gatherInfoBtn.addEventListener('click', () => {
        const socket = new JsSIP.WebSocketInterface('wss://your-sip-server.com');
        const configuration = {
          sockets: [socket],
          uri: 'sip:[email protected]',
        };
        const ua = new JsSIP.UA(configuration);

        const targetURI = 'sip:[email protected]';
        const callOptions = {
          mediaConstraints: { audio: true, video: false },
        };
        const call = ua.call(targetURI, callOptions);

        call.on('accepted', (session) => {
          const callQuality = session.connection.getStats();
          console.log(callQuality);
        });
      });
    });
  </script>
</body>
</html>``
0
cyberlord peace On
  1. Basic Webpage Setup:

    • This part sets up the basic structure of a webpage, like giving it a title and including special software.
  2. Button for Gathering Information:

    • In this step, a button is added to the webpage that you can click to start gathering information about a phone call.
  3. Connecting to the Server:

    • When you click the button, the code connects to a special server over the internet using a secure connection.
  4. Configuring the Connection:

    • This part has settings that tell the computer how to talk to the server and who to call.
  5. Initiating the Call:

    • After the settings are ready, the computer tells the server to make a phone call to a specific number.
  6. Listening to the Call:

    • If the person on the other end answers the call, the computer listens to the call and checks how good the connection is.
  7. Capturing Call Quality:

    • When the call is accepted, the computer collects information about the call's quality, like how clear the sound is.
  8. Logging Call Quality:

    • Lastly, the computer writes down the information about the call's quality so that we can look at it later.