Built motion from commit d5e4af8c.|2.6.23
[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 _0x4e20=['util','ami','asterisk','username','password','Action','promisify','action','error','Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s','port','inspect','format','Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s','actionSipShowRegistry','sipshowregistry','actionDeviceStateList','devicestatelist','actionSipPeerStatus','sippeerstatus','actionQueueSummary','queuesummary','actionCoreShowChannels','coreshowchannels','info','Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s','once','close','connect','shutdown','Fullybooted\x20\x22%s\x22\x20to\x20%s:%s','then','catch','[ami.js][fullybooted]','asterisk-manager','bluebird'];(function(_0x3ab51d,_0x2fa01d){var _0x29a04e=function(_0x7807b0){while(--_0x7807b0){_0x3ab51d['push'](_0x3ab51d['shift']());}};_0x29a04e(++_0x2fa01d);}(_0x4e20,0x142));var _0x04e2=function(_0x11deef,_0x34bbdb){_0x11deef=_0x11deef-0x0;var _0xe9ba85=_0x4e20[_0x11deef];return _0xe9ba85;};'use strict';var Manager=require(_0x04e2('0x0'));var BPromise=require(_0x04e2('0x1'));var util=require(_0x04e2('0x2'));var logger=require('../../config/logger')(_0x04e2('0x3'));var config=require('../../config/environment');var ami=new Manager(config[_0x04e2('0x4')]['port'],config[_0x04e2('0x4')]['ip'],config[_0x04e2('0x4')][_0x04e2('0x5')],config[_0x04e2('0x4')][_0x04e2('0x6')],!![]);ami['keepConnected']();ami[_0x04e2('0x7')]=BPromise[_0x04e2('0x8')](ami[_0x04e2('0x9')]);function error(_0xf3fbd4){logger[_0x04e2('0xa')](util['format'](_0x04e2('0xb'),config[_0x04e2('0x4')][_0x04e2('0x5')],config[_0x04e2('0x4')]['ip'],config[_0x04e2('0x4')][_0x04e2('0xc')],util[_0x04e2('0xd')](_0xf3fbd4,![],null)));}function close(){logger[_0x04e2('0xa')](util[_0x04e2('0xe')](_0x04e2('0xf'),config['asterisk'][_0x04e2('0x5')],config[_0x04e2('0x4')]['ip'],config[_0x04e2('0x4')]['port']));}ami[_0x04e2('0x10')]=function(){return function(){return ami['Action']({'action':_0x04e2('0x11')});};};ami[_0x04e2('0x12')]=function(){return function(){return ami['Action']({'action':_0x04e2('0x13')});};};ami[_0x04e2('0x14')]=function(){return function(){return ami['Action']({'action':_0x04e2('0x15')});};};ami[_0x04e2('0x16')]=function(){return function(){return ami[_0x04e2('0x7')]({'action':_0x04e2('0x17')});};};ami[_0x04e2('0x18')]=function(){return function(){return ami[_0x04e2('0x7')]({'action':_0x04e2('0x19')});};};function connect(){logger[_0x04e2('0x1a')](util[_0x04e2('0xe')](_0x04e2('0x1b'),config[_0x04e2('0x4')][_0x04e2('0x5')],config[_0x04e2('0x4')]['ip'],config['asterisk'][_0x04e2('0xc')]));ami[_0x04e2('0x1c')](_0x04e2('0xa'),error);ami[_0x04e2('0x1c')](_0x04e2('0x1d'),close);}ami['on'](_0x04e2('0x1e'),connect);ami['on'](_0x04e2('0x1f'),function(_0x366214){logger[_0x04e2('0x1a')](util['format']('Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s',config[_0x04e2('0x4')][_0x04e2('0x5')],config[_0x04e2('0x4')]['ip'],config[_0x04e2('0x4')]['port'],util['inspect'](_0x366214,![],null)));});ami['on']('fullybooted',function(){logger['info'](util[_0x04e2('0xe')](_0x04e2('0x20'),config[_0x04e2('0x4')]['username'],config[_0x04e2('0x4')]['ip'],config['asterisk'][_0x04e2('0xc')]));return Promise['resolve']()[_0x04e2('0x21')](ami[_0x04e2('0x10')]())['then'](ami[_0x04e2('0x12')]())['then'](ami[_0x04e2('0x14')]())[_0x04e2('0x21')](ami['actionQueueSummary']())[_0x04e2('0x21')](ami['actionCoreShowChannels']())[_0x04e2('0x22')](function(_0x398408){logger[_0x04e2('0xa')](_0x04e2('0x23'),util['inspect'](_0x398408,{'showHidden':![],'depth':null}));});});ami[_0x04e2('0x1c')](_0x04e2('0xa'),error);ami[_0x04e2('0x1c')]('close',close);module['exports']=ami;