Built motion from commit 936e8062.|2.5.33
[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 _0x3f26=['actionQueueSummary','queuesummary','actionCoreShowChannels','coreshowchannels','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','fullybooted','resolve','then','actionSipPeerStatus','exports','asterisk-manager','bluebird','moment','lodash','ami','../../config/environment','port','asterisk','keepConnected','Action','promisify','action','error','Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s','username','format','Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s','actionSipShowRegistry','sipshowregistry','actionDeviceStateList'];(function(_0x3c2166,_0x41fc16){var _0x30ccc3=function(_0x689bc3){while(--_0x689bc3){_0x3c2166['push'](_0x3c2166['shift']());}};_0x30ccc3(++_0x41fc16);}(_0x3f26,0xa0));var _0x63f2=function(_0x2d270c,_0x1c6c67){_0x2d270c=_0x2d270c-0x0;var _0x51a17c=_0x3f26[_0x2d270c];return _0x51a17c;};'use strict';var Manager=require(_0x63f2('0x0'));var BPromise=require(_0x63f2('0x1'));var moment=require(_0x63f2('0x2'));var util=require('util');var _=require(_0x63f2('0x3'));var logger=require('../../config/logger')(_0x63f2('0x4'));var config=require(_0x63f2('0x5'));var ami=new Manager(config['asterisk'][_0x63f2('0x6')],config[_0x63f2('0x7')]['ip'],config[_0x63f2('0x7')]['username'],config[_0x63f2('0x7')]['password'],!![]);ami[_0x63f2('0x8')]();ami[_0x63f2('0x9')]=BPromise[_0x63f2('0xa')](ami[_0x63f2('0xb')]);function error(_0x38314c){logger[_0x63f2('0xc')](util['format'](_0x63f2('0xd'),config['asterisk'][_0x63f2('0xe')],config['asterisk']['ip'],config[_0x63f2('0x7')]['port'],util['inspect'](_0x38314c,![],null)));}function close(){logger[_0x63f2('0xc')](util[_0x63f2('0xf')](_0x63f2('0x10'),config[_0x63f2('0x7')][_0x63f2('0xe')],config[_0x63f2('0x7')]['ip'],config[_0x63f2('0x7')][_0x63f2('0x6')]));}ami[_0x63f2('0x11')]=function(){return function(){return ami['Action']({'action':_0x63f2('0x12')});};};ami[_0x63f2('0x13')]=function(){return function(){return ami[_0x63f2('0x9')]({'action':'devicestatelist'});};};ami['actionSipPeerStatus']=function(){return function(){return ami[_0x63f2('0x9')]({'action':'sippeerstatus'});};};ami[_0x63f2('0x14')]=function(){return function(){return ami[_0x63f2('0x9')]({'action':_0x63f2('0x15')});};};ami[_0x63f2('0x16')]=function(){return function(){return ami[_0x63f2('0x9')]({'action':_0x63f2('0x17')});};};function connect(_0x4af714){logger[_0x63f2('0x18')](util[_0x63f2('0xf')](_0x63f2('0x19'),config['asterisk'][_0x63f2('0xe')],config[_0x63f2('0x7')]['ip'],config['asterisk'][_0x63f2('0x6')]));ami[_0x63f2('0x1a')](_0x63f2('0xc'),error);ami[_0x63f2('0x1a')](_0x63f2('0x1b'),close);}ami['on'](_0x63f2('0x1c'),connect);ami['on'](_0x63f2('0x1d'),function(_0x2d52d4){logger[_0x63f2('0x18')](util[_0x63f2('0xf')](_0x63f2('0x1e'),config[_0x63f2('0x7')]['username'],config[_0x63f2('0x7')]['ip'],config[_0x63f2('0x7')][_0x63f2('0x6')],util['inspect'](_0x2d52d4,![],null)));});ami['on'](_0x63f2('0x1f'),function(_0x171115){logger['info'](util[_0x63f2('0xf')]('Fullybooted\x20\x22%s\x22\x20to\x20%s:%s',config['asterisk'][_0x63f2('0xe')],config['asterisk']['ip'],config['asterisk'][_0x63f2('0x6')]));return BPromise[_0x63f2('0x20')]()[_0x63f2('0x21')](ami['actionSipShowRegistry']())[_0x63f2('0x21')](ami['actionDeviceStateList']())[_0x63f2('0x21')](ami[_0x63f2('0x22')]())[_0x63f2('0x21')](ami[_0x63f2('0x14')]())[_0x63f2('0x21')](ami[_0x63f2('0x16')]())['catch'](function(_0x3cdd58){console['log'](_0x3cdd58);});});ami[_0x63f2('0x1a')](_0x63f2('0xc'),error);ami['once'](_0x63f2('0x1b'),close);module[_0x63f2('0x23')]=ami;