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