Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / services / ami / ami.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xeabe=['info','Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s','once','close','connect','Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s','fullybooted','Fullybooted\x20\x22%s\x22\x20to\x20%s:%s','resolve','then','[ami.js][fullybooted]','bluebird','ami','../../config/environment','asterisk','username','password','keepConnected','Action','promisify','action','error','format','Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s','inspect','Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s','port','actionSipShowRegistry','sipshowregistry','actionDeviceStateList','actionSipPeerStatus','actionQueueSummary','queuesummary','actionCoreShowChannels','coreshowchannels'];(function(_0x497672,_0x12ffe6){var _0x392c0b=function(_0x52de72){while(--_0x52de72){_0x497672['push'](_0x497672['shift']());}};_0x392c0b(++_0x12ffe6);}(_0xeabe,0xdd));var _0xeeab=function(_0x1c8b26,_0x2b1211){_0x1c8b26=_0x1c8b26-0x0;var _0x52e32b=_0xeabe[_0x1c8b26];return _0x52e32b;};'use strict';var Manager=require('asterisk-manager');var BPromise=require(_0xeeab('0x0'));var util=require('util');var logger=require('../../config/logger')(_0xeeab('0x1'));var config=require(_0xeeab('0x2'));var ami=new Manager(config[_0xeeab('0x3')]['port'],config[_0xeeab('0x3')]['ip'],config[_0xeeab('0x3')][_0xeeab('0x4')],config[_0xeeab('0x3')][_0xeeab('0x5')],!![]);ami[_0xeeab('0x6')]();ami[_0xeeab('0x7')]=BPromise[_0xeeab('0x8')](ami[_0xeeab('0x9')]);function error(_0x3dac4a){logger[_0xeeab('0xa')](util[_0xeeab('0xb')](_0xeeab('0xc'),config['asterisk']['username'],config[_0xeeab('0x3')]['ip'],config[_0xeeab('0x3')]['port'],util[_0xeeab('0xd')](_0x3dac4a,![],null)));}function close(){logger[_0xeeab('0xa')](util[_0xeeab('0xb')](_0xeeab('0xe'),config['asterisk'][_0xeeab('0x4')],config[_0xeeab('0x3')]['ip'],config[_0xeeab('0x3')][_0xeeab('0xf')]));}ami[_0xeeab('0x10')]=function(){return function(){return ami[_0xeeab('0x7')]({'action':_0xeeab('0x11')});};};ami[_0xeeab('0x12')]=function(){return function(){return ami[_0xeeab('0x7')]({'action':'devicestatelist'});};};ami[_0xeeab('0x13')]=function(){return function(){return ami[_0xeeab('0x7')]({'action':'sippeerstatus'});};};ami[_0xeeab('0x14')]=function(){return function(){return ami[_0xeeab('0x7')]({'action':_0xeeab('0x15')});};};ami[_0xeeab('0x16')]=function(){return function(){return ami[_0xeeab('0x7')]({'action':_0xeeab('0x17')});};};function connect(){logger[_0xeeab('0x18')](util[_0xeeab('0xb')](_0xeeab('0x19'),config['asterisk'][_0xeeab('0x4')],config[_0xeeab('0x3')]['ip'],config[_0xeeab('0x3')][_0xeeab('0xf')]));ami[_0xeeab('0x1a')](_0xeeab('0xa'),error);ami[_0xeeab('0x1a')](_0xeeab('0x1b'),close);}ami['on'](_0xeeab('0x1c'),connect);ami['on']('shutdown',function(_0x42e629){logger['info'](util[_0xeeab('0xb')](_0xeeab('0x1d'),config[_0xeeab('0x3')][_0xeeab('0x4')],config[_0xeeab('0x3')]['ip'],config[_0xeeab('0x3')][_0xeeab('0xf')],util[_0xeeab('0xd')](_0x42e629,![],null)));});ami['on'](_0xeeab('0x1e'),function(){logger[_0xeeab('0x18')](util['format'](_0xeeab('0x1f'),config[_0xeeab('0x3')][_0xeeab('0x4')],config[_0xeeab('0x3')]['ip'],config[_0xeeab('0x3')][_0xeeab('0xf')]));return Promise[_0xeeab('0x20')]()[_0xeeab('0x21')](ami[_0xeeab('0x10')]())['then'](ami[_0xeeab('0x12')]())['then'](ami[_0xeeab('0x13')]())[_0xeeab('0x21')](ami[_0xeeab('0x14')]())[_0xeeab('0x21')](ami['actionCoreShowChannels']())['catch'](function(_0x522148){logger['error'](_0xeeab('0x22'),util[_0xeeab('0xd')](_0x522148,{'showHidden':![],'depth':null}));});});ami[_0xeeab('0x1a')]('error',error);ami[_0xeeab('0x1a')](_0xeeab('0x1b'),close);module['exports']=ami;