// Creates the user agent
var userAgent = new SIP.UA({
uri : '<ext>@<server_url>',
wsServers : ['ws://<server_url>:8088/ws'],
authorizationUser: '<ext>',
password : '<ext_password>',
hackIpInContact : true
});
// Call options
var options = {
media: {
constraints: {
audio: true,
video: false
},
render: {
remote: {
audio: document.getElementById('example-audio-tag'),
},
},
},
extraHeaders : [ #SIP headers for Click2Dial Settings
'X-Platforma-Outbound-ID:<outbound_id>',
'X-Platforma-Contact-Ref:<custom_call_ref>'
]
};
// Make the call
var session = userAgent.invite('sip:<callee>@<server_url>', options);
// Error while placing a call
session.on('failed', function (request) {
//http://sipjs.com/api/0.7.0/causes/
console.log('Call Failed');
//We send back special error messages for validation errors.
var validationErrors = request.getHeaders('X-Platforma-Error');
if (0 < validationErrors.length) {
validationErrors.forEach(function(error) {
console.log('Validation Error: ', error);
});
}
}); |