Built motion from commit 4ffc18b1.|2.6.31
[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 _0xe7de=['once','close','shutdown','Fullybooted\x20\x22%s\x22\x20to\x20%s:%s','then','actionSipShowRegistry','actionSipPeerStatus','catch','[ami.js][fullybooted]','exports','asterisk-manager','bluebird','util','../../config/logger','../../config/environment','asterisk','port','username','password','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','Action','actionDeviceStateList','devicestatelist','sippeerstatus','actionQueueSummary','queuesummary','actionCoreShowChannels','coreshowchannels','info','Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s'];(function(_0x15778d,_0x4a2e0b){var _0x37c645=function(_0x3086aa){while(--_0x3086aa){_0x15778d['push'](_0x15778d['shift']());}};_0x37c645(++_0x4a2e0b);}(_0xe7de,0x73));var _0xee7d=function(_0x1d845c,_0x33fca3){_0x1d845c=_0x1d845c-0x0;var _0x2049e3=_0xe7de[_0x1d845c];return _0x2049e3;};'use strict';var Manager=require(_0xee7d('0x0'));var BPromise=require(_0xee7d('0x1'));var util=require(_0xee7d('0x2'));var logger=require(_0xee7d('0x3'))('ami');var config=require(_0xee7d('0x4'));var ami=new Manager(config[_0xee7d('0x5')][_0xee7d('0x6')],config[_0xee7d('0x5')]['ip'],config['asterisk'][_0xee7d('0x7')],config['asterisk'][_0xee7d('0x8')],!![]);ami['keepConnected']();ami['Action']=BPromise[_0xee7d('0x9')](ami['action']);function error(_0x57cfb0){logger['error'](util[_0xee7d('0xa')](_0xee7d('0xb'),config[_0xee7d('0x5')][_0xee7d('0x7')],config[_0xee7d('0x5')]['ip'],config[_0xee7d('0x5')][_0xee7d('0x6')],util[_0xee7d('0xc')](_0x57cfb0,![],null)));}function close(){logger[_0xee7d('0xd')](util[_0xee7d('0xa')](_0xee7d('0xe'),config[_0xee7d('0x5')][_0xee7d('0x7')],config[_0xee7d('0x5')]['ip'],config[_0xee7d('0x5')][_0xee7d('0x6')]));}ami['actionSipShowRegistry']=function(){return function(){return ami[_0xee7d('0xf')]({'action':'sipshowregistry'});};};ami[_0xee7d('0x10')]=function(){return function(){return ami[_0xee7d('0xf')]({'action':_0xee7d('0x11')});};};ami['actionSipPeerStatus']=function(){return function(){return ami[_0xee7d('0xf')]({'action':_0xee7d('0x12')});};};ami[_0xee7d('0x13')]=function(){return function(){return ami[_0xee7d('0xf')]({'action':_0xee7d('0x14')});};};ami[_0xee7d('0x15')]=function(){return function(){return ami[_0xee7d('0xf')]({'action':_0xee7d('0x16')});};};function connect(){logger[_0xee7d('0x17')](util[_0xee7d('0xa')](_0xee7d('0x18'),config['asterisk'][_0xee7d('0x7')],config[_0xee7d('0x5')]['ip'],config[_0xee7d('0x5')][_0xee7d('0x6')]));ami[_0xee7d('0x19')](_0xee7d('0xd'),error);ami['once'](_0xee7d('0x1a'),close);}ami['on']('connect',connect);ami['on'](_0xee7d('0x1b'),function(_0xc5e964){logger[_0xee7d('0x17')](util['format']('Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s',config['asterisk'][_0xee7d('0x7')],config[_0xee7d('0x5')]['ip'],config['asterisk'][_0xee7d('0x6')],util[_0xee7d('0xc')](_0xc5e964,![],null)));});ami['on']('fullybooted',function(){logger[_0xee7d('0x17')](util['format'](_0xee7d('0x1c'),config['asterisk'][_0xee7d('0x7')],config[_0xee7d('0x5')]['ip'],config[_0xee7d('0x5')][_0xee7d('0x6')]));return Promise['resolve']()[_0xee7d('0x1d')](ami[_0xee7d('0x1e')]())[_0xee7d('0x1d')](ami[_0xee7d('0x10')]())[_0xee7d('0x1d')](ami[_0xee7d('0x1f')]())[_0xee7d('0x1d')](ami[_0xee7d('0x13')]())[_0xee7d('0x1d')](ami[_0xee7d('0x15')]())[_0xee7d('0x20')](function(_0x56bf9a){logger[_0xee7d('0xd')](_0xee7d('0x21'),util['inspect'](_0x56bf9a,{'showHidden':![],'depth':null}));});});ami[_0xee7d('0x19')](_0xee7d('0xd'),error);ami[_0xee7d('0x19')]('close',close);module[_0xee7d('0x22')]=ami;