Built motion from commit (unavailable).|2.4.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 _0x3a41=['promisify','action','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','actionSipShowRegistry','Action','actionSipPeerStatus','sippeerstatus','actionQueueSummary','queuesummary','actionCoreShowChannels','coreshowchannels','info','Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s','once','error','close','connect','shutdown','Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s','Fullybooted\x20\x22%s\x22\x20to\x20%s:%s','resolve','then','actionDeviceStateList','catch','exports','asterisk-manager','bluebird','moment','util','lodash','../../config/logger','ami','asterisk','port','username','password','keepConnected'];(function(_0x408c06,_0x5865b9){var _0x27cf44=function(_0x14e3e4){while(--_0x14e3e4){_0x408c06['push'](_0x408c06['shift']());}};_0x27cf44(++_0x5865b9);}(_0x3a41,0x1d4));var _0x13a4=function(_0x52cbe0,_0x332b2e){_0x52cbe0=_0x52cbe0-0x0;var _0x4bb9da=_0x3a41[_0x52cbe0];return _0x4bb9da;};'use strict';var Manager=require(_0x13a4('0x0'));var BPromise=require(_0x13a4('0x1'));var moment=require(_0x13a4('0x2'));var util=require(_0x13a4('0x3'));var _=require(_0x13a4('0x4'));var logger=require(_0x13a4('0x5'))(_0x13a4('0x6'));var config=require('../../config/environment');var ami=new Manager(config[_0x13a4('0x7')][_0x13a4('0x8')],config[_0x13a4('0x7')]['ip'],config[_0x13a4('0x7')][_0x13a4('0x9')],config[_0x13a4('0x7')][_0x13a4('0xa')],!![]);ami[_0x13a4('0xb')]();ami['Action']=BPromise[_0x13a4('0xc')](ami[_0x13a4('0xd')]);function error(_0x187ca3){logger['error'](util[_0x13a4('0xe')](_0x13a4('0xf'),config[_0x13a4('0x7')][_0x13a4('0x9')],config[_0x13a4('0x7')]['ip'],config['asterisk'][_0x13a4('0x8')],util[_0x13a4('0x10')](_0x187ca3,![],null)));}function close(){logger['error'](util[_0x13a4('0xe')](_0x13a4('0x11'),config[_0x13a4('0x7')]['username'],config[_0x13a4('0x7')]['ip'],config[_0x13a4('0x7')][_0x13a4('0x8')]));}ami[_0x13a4('0x12')]=function(){return function(){return ami['Action']({'action':'sipshowregistry'});};};ami['actionDeviceStateList']=function(){return function(){return ami[_0x13a4('0x13')]({'action':'devicestatelist'});};};ami[_0x13a4('0x14')]=function(){return function(){return ami[_0x13a4('0x13')]({'action':_0x13a4('0x15')});};};ami[_0x13a4('0x16')]=function(){return function(){return ami['Action']({'action':_0x13a4('0x17')});};};ami[_0x13a4('0x18')]=function(){return function(){return ami['Action']({'action':_0x13a4('0x19')});};};function connect(_0x1b5c0a){logger[_0x13a4('0x1a')](util['format'](_0x13a4('0x1b'),config[_0x13a4('0x7')][_0x13a4('0x9')],config[_0x13a4('0x7')]['ip'],config[_0x13a4('0x7')][_0x13a4('0x8')]));ami[_0x13a4('0x1c')](_0x13a4('0x1d'),error);ami[_0x13a4('0x1c')](_0x13a4('0x1e'),close);}ami['on'](_0x13a4('0x1f'),connect);ami['on'](_0x13a4('0x20'),function(_0x2edaf9){logger[_0x13a4('0x1a')](util['format'](_0x13a4('0x21'),config['asterisk']['username'],config[_0x13a4('0x7')]['ip'],config[_0x13a4('0x7')][_0x13a4('0x8')],util[_0x13a4('0x10')](_0x2edaf9,![],null)));});ami['on']('fullybooted',function(_0x1023f3){logger[_0x13a4('0x1a')](util['format'](_0x13a4('0x22'),config[_0x13a4('0x7')][_0x13a4('0x9')],config[_0x13a4('0x7')]['ip'],config[_0x13a4('0x7')][_0x13a4('0x8')]));return BPromise[_0x13a4('0x23')]()['then'](ami[_0x13a4('0x12')]())[_0x13a4('0x24')](ami[_0x13a4('0x25')]())[_0x13a4('0x24')](ami[_0x13a4('0x14')]())[_0x13a4('0x24')](ami[_0x13a4('0x16')]())[_0x13a4('0x24')](ami['actionCoreShowChannels']())[_0x13a4('0x26')](function(_0x2afa3d){console['log'](_0x2afa3d);});});ami[_0x13a4('0x1c')]('error',error);ami[_0x13a4('0x1c')](_0x13a4('0x1e'),close);module[_0x13a4('0x27')]=ami;