<html>
<head>
<title>Example SIP Phone</title>
<script src="./sip-0.15.11.js"></script>
</head>
<body>
<p>
Softphone Registered: <span id="registeredDate"></span><br/>
Invite Received: <span id="invitedDate"></span><br/>
Session Begin: <span id="sessionBeginDate"></span><br/>
Session End: <span id="sessionEndDate"></span><br/>
</p>
<script src="./example-sip-phone.js"></script>
<script>
getUserDetails = function(){
const username = "{unixTimeStamp}:{customerID}--{userID}--{username}";
const password = encryptStringWithHmacSHA1(username, {authSecret})
return {
"authorizationUser":"username",
"transportOptions":
{
"traceSip":true,
"wsServers":[
{
"wsUri":"{wsURL}",
"sipUri":"sipURL",
"weight":0,
"isError":false,
"scheme":"WSS"
}]},
"sessionDescriptionHandlerFactoryOptions":
{
"peerConnectionConfiguration":
{
"iceServers":[
{
"urls":"stun:stun.l.google.com:19302",
"username":null,
"credential":null
},
{
"urls":"{turnURL}",
"username":"{username}",
"credential":"{password}"
}]}},
"userAgentString":"OmniSenseSIPPhone",
"rtcpMuxPolicy":"negotiate",
"uri":"[CUSTOMER_ID--USER_ID--AGENTLOGIN]@{webrtcURL}",
"password":"{password}"
}
}
// Create an instance of the SipPhone and wire up events
ExampleSipPhone = new SipPhone({
credentials: getUserDetails(),
onRegistered: function(){
console.log("Softphone registered.");
registeredDate.textContent = new Date().toISOString();
},
onInviteReceived: function(){
console.log("A SIP invite has been received.");
invitedDate.textContent = new Date().toISOString();
},
onSessionBegin: function(){
console.log("The SIP session has started.");
sessionBeginDate.textContent = new Date().toISOString();
},
onSessionEnd:function(){
console.log("The SIP session has ended.");
sessionEndDate.textContent = new Date().toISOString();
}
});
</script>
</body>
</html> |