Advertisement
Guest User

AMI

a guest
May 31st, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * port:  port server
  3.  * host: host server
  4.  * username: username for authentication
  5.  * password: username's password for authentication
  6.  * events: this parameter determines whether events are emited.
  7.  **/
  8.  
  9.  
  10. var ami = new require('asterisk-manager')('5038', '----', 'LOGIN', 'YOUR_PASS', true);
  11.  
  12. // In case of any connectiviy problems we got you coverd.
  13. ami.keepConnected();
  14.  
  15. ami.on('connect', function (evt) {
  16.  
  17. });
  18.  
  19. ami.on('response', function (evt) {
  20. });
  21.  
  22.  
  23. // Listen for any/all AMI events.
  24. ami.on('managerevent', function (evt) {
  25.  
  26.     // console.log(evt);
  27.     //Убиваем звонки )
  28.     // ami.action({
  29.     //     'action':'Hangup',
  30.     //     'channel': evt.channel,
  31.     //     'Uniqueid': evt.uniqueid,
  32.     //     'cause': '17',
  33.     //     'cause-txt': 'User busy'
  34.     // }, function(err, res) {
  35.     //     console.log(res);
  36.     // });
  37.  
  38.    
  39.     // Переадресовываем
  40.     // ami.action({
  41.     //     'action': 'redirect',
  42.     //     'channel': evt.channel,
  43.     //     'context': 'office',
  44.     //     'exten': '103', //куда будем переадресовывать
  45.     //     // 'ExtraExten': '113',
  46.     //     'priority': '1',
  47.     //     'ExtraPriority': '2'
  48.     // }, function (err, res) {
  49.     //     console.log(res);
  50.     // });
  51.  
  52.     //Звоним абоненту
  53.     // ami.action({
  54.     //     'action': 'originate',
  55.     //     'channel': "SIP/112",
  56.     //     'exten': '113',
  57.     //     'context': 'office',
  58.     //     'priority': '1'
  59.     // }, function (err, res) {
  60.     //     console.log(res);
  61.     // });
  62.    
  63. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement