Tutorial step 5:

Step 5: Making Calls

To be able to call someone wrtc needs to know the username of the person to call:

<!DOCTYPE html>
<html><head>
<script type="module">
import { wrtcObject} from "/luci-static/resources/wrtc_kit_m.js";
const wrtc = new wrtcObject(function() {
this.wsServer = "50.11.69.17";
});
function ChangeName() {
wrtc.changeCredentials({addressName: document.getElementById('myname').value,
sipPassword: document.getElementById('mypwd').value});
};
document.getElementById('okbtn').addEventListener('click', ChangeName);
document.getElementById('callbtn').addEventListener('click',
function() {wrtc.call(document.getElementById('dial').value)});

</script>
</head><body>
<div>
Name:<input type="text" id="myname"><br/>
Pwd :<input type="password" id="mypwd"><br/>
<button id="okbtn">OK</button><br/>
<input type="text" id="dial"><button id="callbtn">Call</button>
</div>
<video id="localVideo" width="200px" autoplay="autoplay" muted="true"></video>
<video id="remoteVideo" width="300px" autoplay="autoplay"></video>
</body></html>

Yes, it is really that simple to call anyone. And yes, I am sure you will make a nicer dial field too.

Calling someone is as simple as calling function wrtc.call() with that person's username as argument.

If the argument name is a valid username logged in to some other WebRTC client connected to the same IXNX unit the call will be placed to there.

If there is no-one connected with such a username the argument will be sent to the IXNX unit's SIP proxy as a SIP address, and if a suitable SIP client with that address is found a SIP call will be set up between that SIP client and your WebRTC client. You do not need to perform any extra activity to add SIP communication to your WebRTC client. Further, the IXNX unit takes care of any media decryption needed to be able to communicate with older SIP clients that cannot encrypt media.

Actually the above code is enough to make calls! But you still cannot receive calls, and you cannot end calls. We need to add a little more code to this client:

Step 6: Events

ixnx/wrtc/js/tutorial/step5.txt · Last modified: by migration
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0