Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function registerUA() {
- console.log("Iniciando creación del UA SIP....");
- //Configuración de conexión
- var configuration = {
- uri: "sip:1001@"+webserver,
- password: xxxx,
- ws_servers: "ws://"+webserver+":8088/asterisk/ws",
- display_name: "UA WebRTC",
- authorization_user: null,
- register: null,
- register_expires: null,
- no_answer_timeout: null,
- trace_sip: true,
- stun_servers: null,
- turn_servers: null,
- use_preloaded_route: null,
- connection_recovery_min_interval: null,
- connection_recovery_max_interval: null,
- hack_via_tcp: null,
- hack_ip_in_contact: true
- };
- //Registrar el softphone
- ua = new JsSIP.UA(configuration);
- ua.start();
- }
- ////////////////////////////////////////////////////
- //Hace una llamada al número en el cuadro de texto//
- ////////////////////////////////////////////////////
- function callAsterisk() {
- console.log("Intentando hacer una llamada ....");
- var numTel = document.getElementById('txtNumero').value;
- console.log(numTel);
- //DOM de contenedores de video
- var myMultimedia = document.getElementById('myMultimedia');
- var theirMultimedia = document.getElementById('theirMultimedia');
- // Register callbacks to desired call events
- var eventH = {
- 'progress': function (e) {
- console.log('LLAMADA EN PROGRESO ...........');
- },
- 'failed': function (e) {
- console.log('LA LLAMADA FALLÓ DEBIDO A: ' + e.data.cause);
- },
- 'ended': function (e) {
- console.log('YA TERMINÓ LA LLAMADA: ');
- },
- 'confirmed': function (e) {
- local_stream = session.connection.getLocalStreams()[0];
- console.log('LLAMADA CONFIRMADA');
- console.log(local_stream);
- // Attach local stream to selfView
- //myMultimedia = JsSIP.rtcninja.attachMediaStream(myMultimedia, local_stream);
- console.log(local_stream);
- },
- 'addstream': function (e) {
- remote_stream = e.stream;
- console.log('FLUJO REMOTO RECIBIDO');
- console.log(remote_stream);
- // Attach remote stream to remoteView
- theirMultimedia = JsSIP.rtcninja.attachMediaStream(theirMultimedia, remote_stream);
- console.log(remote_stream);
- }
- };
- //parámetros de la llamada
- var options = {
- 'eventHandlers': eventH,
- 'mediaConstraints': {
- 'audio': true,
- 'video': false
- }
- };
- //Llamando
- session = ua.call('sip:' + numTel + '@'+webserver, options);
- console.log("Marcando ....");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement