Built motion from commit (unavailable).|2.5.11
[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 _0x43e7=['../../config/logger','../../config/environment','asterisk','port','username','password','keepConnected','Action','action','error','format','Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s','inspect','actionSipShowRegistry','sipshowregistry','actionDeviceStateList','devicestatelist','actionSipPeerStatus','sippeerstatus','actionQueueSummary','queuesummary','actionCoreShowChannels','coreshowchannels','Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s','once','close','connect','Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s','fullybooted','info','Fullybooted\x20\x22%s\x22\x20to\x20%s:%s','resolve','then','catch','log','asterisk-manager','bluebird','moment','util'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x43e7,0x134));var _0x743e=function(_0x38b14f,_0xd08fa8){_0x38b14f=_0x38b14f-0x0;var _0x22a324=_0x43e7[_0x38b14f];return _0x22a324;};'use strict';var Manager=require(_0x743e('0x0'));var BPromise=require(_0x743e('0x1'));var moment=require(_0x743e('0x2'));var util=require(_0x743e('0x3'));var _=require('lodash');var logger=require(_0x743e('0x4'))('ami');var config=require(_0x743e('0x5'));var ami=new Manager(config[_0x743e('0x6')][_0x743e('0x7')],config[_0x743e('0x6')]['ip'],config[_0x743e('0x6')][_0x743e('0x8')],config['asterisk'][_0x743e('0x9')],!![]);ami[_0x743e('0xa')]();ami[_0x743e('0xb')]=BPromise['promisify'](ami[_0x743e('0xc')]);function error(_0x477422){logger[_0x743e('0xd')](util[_0x743e('0xe')](_0x743e('0xf'),config['asterisk'][_0x743e('0x8')],config[_0x743e('0x6')]['ip'],config[_0x743e('0x6')][_0x743e('0x7')],util[_0x743e('0x10')](_0x477422,![],null)));}function close(){logger[_0x743e('0xd')](util['format']('Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s',config[_0x743e('0x6')][_0x743e('0x8')],config[_0x743e('0x6')]['ip'],config['asterisk']['port']));}ami[_0x743e('0x11')]=function(){return function(){return ami[_0x743e('0xb')]({'action':_0x743e('0x12')});};};ami[_0x743e('0x13')]=function(){return function(){return ami[_0x743e('0xb')]({'action':_0x743e('0x14')});};};ami[_0x743e('0x15')]=function(){return function(){return ami[_0x743e('0xb')]({'action':_0x743e('0x16')});};};ami[_0x743e('0x17')]=function(){return function(){return ami['Action']({'action':_0x743e('0x18')});};};ami[_0x743e('0x19')]=function(){return function(){return ami[_0x743e('0xb')]({'action':_0x743e('0x1a')});};};function connect(_0x2a8d61){logger['info'](util[_0x743e('0xe')](_0x743e('0x1b'),config['asterisk'][_0x743e('0x8')],config[_0x743e('0x6')]['ip'],config['asterisk'][_0x743e('0x7')]));ami[_0x743e('0x1c')](_0x743e('0xd'),error);ami[_0x743e('0x1c')](_0x743e('0x1d'),close);}ami['on'](_0x743e('0x1e'),connect);ami['on']('shutdown',function(_0x38ea23){logger['info'](util[_0x743e('0xe')](_0x743e('0x1f'),config[_0x743e('0x6')][_0x743e('0x8')],config[_0x743e('0x6')]['ip'],config['asterisk']['port'],util[_0x743e('0x10')](_0x38ea23,![],null)));});ami['on'](_0x743e('0x20'),function(_0x28fb79){logger[_0x743e('0x21')](util[_0x743e('0xe')](_0x743e('0x22'),config[_0x743e('0x6')]['username'],config['asterisk']['ip'],config[_0x743e('0x6')][_0x743e('0x7')]));return BPromise[_0x743e('0x23')]()[_0x743e('0x24')](ami[_0x743e('0x11')]())[_0x743e('0x24')](ami[_0x743e('0x13')]())[_0x743e('0x24')](ami[_0x743e('0x15')]())[_0x743e('0x24')](ami[_0x743e('0x17')]())[_0x743e('0x24')](ami[_0x743e('0x19')]())[_0x743e('0x25')](function(_0x16c2ab){console[_0x743e('0x26')](_0x16c2ab);});});ami['once'](_0x743e('0xd'),error);ami[_0x743e('0x1c')](_0x743e('0x1d'),close);module['exports']=ami;