ff85c1c79b7cbb5e2c05a09c3a2ab6fd6dba5f6d
[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 _0x34ea=['close','shutdown','Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s','fullybooted','Fullybooted\x20\x22%s\x22\x20to\x20%s:%s','then','actionQueueSummary','once','exports','asterisk-manager','bluebird','util','../../config/logger','ami','../../config/environment','port','asterisk','username','Action','promisify','format','Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s','inspect','error','Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s','actionSipShowRegistry','sipshowregistry','actionDeviceStateList','devicestatelist','actionSipPeerStatus','sippeerstatus','queuesummary','actionCoreShowChannels','info','Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x34ea,0x18a));var _0xa34e=function(_0x52c6e8,_0x5e5692){_0x52c6e8=_0x52c6e8-0x0;var _0x335328=_0x34ea[_0x52c6e8];return _0x335328;};'use strict';var Manager=require(_0xa34e('0x0'));var BPromise=require(_0xa34e('0x1'));var util=require(_0xa34e('0x2'));var logger=require(_0xa34e('0x3'))(_0xa34e('0x4'));var config=require(_0xa34e('0x5'));var ami=new Manager(config['asterisk'][_0xa34e('0x6')],config[_0xa34e('0x7')]['ip'],config[_0xa34e('0x7')][_0xa34e('0x8')],config[_0xa34e('0x7')]['password'],!![]);ami['keepConnected']();ami[_0xa34e('0x9')]=BPromise[_0xa34e('0xa')](ami['action']);function error(_0xf4be19){logger['error'](util[_0xa34e('0xb')](_0xa34e('0xc'),config[_0xa34e('0x7')][_0xa34e('0x8')],config[_0xa34e('0x7')]['ip'],config[_0xa34e('0x7')][_0xa34e('0x6')],util[_0xa34e('0xd')](_0xf4be19,![],null)));}function close(){logger[_0xa34e('0xe')](util[_0xa34e('0xb')](_0xa34e('0xf'),config[_0xa34e('0x7')][_0xa34e('0x8')],config[_0xa34e('0x7')]['ip'],config[_0xa34e('0x7')][_0xa34e('0x6')]));}ami[_0xa34e('0x10')]=function(){return function(){return ami[_0xa34e('0x9')]({'action':_0xa34e('0x11')});};};ami[_0xa34e('0x12')]=function(){return function(){return ami[_0xa34e('0x9')]({'action':_0xa34e('0x13')});};};ami[_0xa34e('0x14')]=function(){return function(){return ami[_0xa34e('0x9')]({'action':_0xa34e('0x15')});};};ami['actionQueueSummary']=function(){return function(){return ami[_0xa34e('0x9')]({'action':_0xa34e('0x16')});};};ami[_0xa34e('0x17')]=function(){return function(){return ami[_0xa34e('0x9')]({'action':'coreshowchannels'});};};function connect(){logger[_0xa34e('0x18')](util[_0xa34e('0xb')](_0xa34e('0x19'),config[_0xa34e('0x7')][_0xa34e('0x8')],config[_0xa34e('0x7')]['ip'],config['asterisk'][_0xa34e('0x6')]));ami['once'](_0xa34e('0xe'),error);ami['once'](_0xa34e('0x1a'),close);}ami['on']('connect',connect);ami['on'](_0xa34e('0x1b'),function(_0x18b0eb){logger[_0xa34e('0x18')](util[_0xa34e('0xb')](_0xa34e('0x1c'),config[_0xa34e('0x7')][_0xa34e('0x8')],config[_0xa34e('0x7')]['ip'],config[_0xa34e('0x7')]['port'],util[_0xa34e('0xd')](_0x18b0eb,![],null)));});ami['on'](_0xa34e('0x1d'),function(){logger[_0xa34e('0x18')](util['format'](_0xa34e('0x1e'),config[_0xa34e('0x7')]['username'],config['asterisk']['ip'],config['asterisk'][_0xa34e('0x6')]));return Promise['resolve']()[_0xa34e('0x1f')](ami['actionSipShowRegistry']())[_0xa34e('0x1f')](ami[_0xa34e('0x12')]())[_0xa34e('0x1f')](ami[_0xa34e('0x14')]())['then'](ami[_0xa34e('0x20')]())['then'](ami[_0xa34e('0x17')]())['catch'](function(_0x32634e){logger[_0xa34e('0xe')]('[ami.js][fullybooted]',util[_0xa34e('0xd')](_0x32634e,{'showHidden':![],'depth':null}));});});ami[_0xa34e('0x21')](_0xa34e('0xe'),error);ami['once'](_0xa34e('0x1a'),close);module[_0xa34e('0x22')]=ami;