Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

sábado, 17 de octubre de 2015

Asterisk node.js event

EVENT ASTERISK MANAGER

 
 
 
 
 
 
Rate This

npm install asterisk-manager
/home/node_modules/asterisk-manager/lib/test.js
test.js
var ami = new require(‘asterisk-manager’)(‘5038′,’192.168.0.105′,’username’,’password’, true);
// Listen for any/all AMI events.
ami.on(‘managerevent’, function(evt) {
console.log(‘EVENT ::’, evt);
});
// Listen for specific AMI events. A list of event names can be found at
// https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+AMI+Events
ami.on(‘hangup’, function(evt) {
console.log(‘HANGUP ::’, evt);
});
ami.on(‘confbridgejoin’, function(evt) {
console.log(‘CONFBRIDGEJOIN ::’, evt);
});
ami.on(‘close’, function(e) {
console.log(‘CLOSE ::’, e);
});
ami.on(‘disconnect’, function(e) {
console.log(‘DISCONNECT ::’, e);
});
ami.on(‘connect’, function(e) {
console.log(‘CONNECT ::’, e);
});
ami.action({
‘action’:’originate’,
‘channel’:’SIP/4001′,
‘context’:’default’,
‘exten’:1234,
‘priority’:1,
‘variables’:{
‘name1′:’value1’,
‘name2′:’value2’
}
}, function(err, res) {});


////////////////////

/**
 * port:  port server
 * host: host server
 * username: username for authentication
 * password: username's password for authentication
 * events: this parameter determines whether events are emited.
 **/
var ami = new require('asterisk-manager')('5038','localhost','admin','mypass456', true);

// In case of any connectiviy problems we got you coverd.
ami.keepConnected();


// Listen for any/all AMI events.
ami.on('managerevent', function(evt) {

});

// Listen for specific AMI events. A list of event names can be found at
// https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+AMI+Events
ami.on('hangup', function(evt) {

console.log('hangup ::', evt);
});
ami.on('confbridgejoin', function(evt) {});

// Listen for Action responses.
ami.on('response', function(evt) {});

// Perform an AMI Action. A list of actions can be found at
// https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+AMI+Actions
ami.action({
  'action':'originate',
  'channel':'SIP/102',
  'context':'internal',
  'exten':0,
  'priority':1,
  'variable':{
    'name1':'value1',
    'name2':'value2'
  }
}, function(err, res) {});


event ouput on hangup

hangup :: { event: 'Hangup',
  privilege: 'call,all',
  channel: 'SIP/102-00000003',
  channelstate: '6',
  channelstatedesc: 'Up',
  calleridnum: '102',
  calleridname: '<unknown>',
  connectedlinenum: '<unknown>',
  connectedlinename: '<unknown>',
  accountcode: '',
  context: 'internal',
  exten: 'h',
  priority: '2',
  uniqueid: '1445151668.6',
  cause: '16',
  'cause-txt': 'Normal Clearing' }

No hay comentarios:

Publicar un comentario