58744327caafec317b396d903b9054ae20d8eb5d
[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 _0xe3f7=['promisify','error','Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s','inspect','format','Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s','actionSipShowRegistry','sipshowregistry','actionDeviceStateList','Action','sippeerstatus','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','Fullybooted\x20\x22%s\x22\x20to\x20%s:%s','resolve','then','actionSipPeerStatus','exports','asterisk-manager','bluebird','moment','lodash','../../config/logger','ami','../../config/environment','asterisk','port','username','password'];(function(_0x3dc6cf,_0x3e0624){var _0x4e6e5e=function(_0x1d36f9){while(--_0x1d36f9){_0x3dc6cf['push'](_0x3dc6cf['shift']());}};_0x4e6e5e(++_0x3e0624);}(_0xe3f7,0x12d));var _0x7e3f=function(_0x27b83e,_0x1f5bb8){_0x27b83e=_0x27b83e-0x0;var _0x566e70=_0xe3f7[_0x27b83e];return _0x566e70;};'use strict';var Manager=require(_0x7e3f('0x0'));var BPromise=require(_0x7e3f('0x1'));var moment=require(_0x7e3f('0x2'));var util=require('util');var _=require(_0x7e3f('0x3'));var logger=require(_0x7e3f('0x4'))(_0x7e3f('0x5'));var config=require(_0x7e3f('0x6'));var ami=new Manager(config[_0x7e3f('0x7')][_0x7e3f('0x8')],config[_0x7e3f('0x7')]['ip'],config[_0x7e3f('0x7')][_0x7e3f('0x9')],config['asterisk'][_0x7e3f('0xa')],!![]);ami['keepConnected']();ami['Action']=BPromise[_0x7e3f('0xb')](ami['action']);function error(_0x1848eb){logger[_0x7e3f('0xc')](util['format'](_0x7e3f('0xd'),config[_0x7e3f('0x7')][_0x7e3f('0x9')],config[_0x7e3f('0x7')]['ip'],config[_0x7e3f('0x7')][_0x7e3f('0x8')],util[_0x7e3f('0xe')](_0x1848eb,![],null)));}function close(){logger[_0x7e3f('0xc')](util[_0x7e3f('0xf')](_0x7e3f('0x10'),config[_0x7e3f('0x7')][_0x7e3f('0x9')],config[_0x7e3f('0x7')]['ip'],config[_0x7e3f('0x7')][_0x7e3f('0x8')]));}ami[_0x7e3f('0x11')]=function(){return function(){return ami['Action']({'action':_0x7e3f('0x12')});};};ami[_0x7e3f('0x13')]=function(){return function(){return ami[_0x7e3f('0x14')]({'action':'devicestatelist'});};};ami['actionSipPeerStatus']=function(){return function(){return ami[_0x7e3f('0x14')]({'action':_0x7e3f('0x15')});};};ami[_0x7e3f('0x16')]=function(){return function(){return ami[_0x7e3f('0x14')]({'action':_0x7e3f('0x17')});};};ami[_0x7e3f('0x18')]=function(){return function(){return ami[_0x7e3f('0x14')]({'action':_0x7e3f('0x19')});};};function connect(_0x1223b3){logger[_0x7e3f('0x1a')](util[_0x7e3f('0xf')](_0x7e3f('0x1b'),config[_0x7e3f('0x7')][_0x7e3f('0x9')],config['asterisk']['ip'],config[_0x7e3f('0x7')][_0x7e3f('0x8')]));ami[_0x7e3f('0x1c')](_0x7e3f('0xc'),error);ami[_0x7e3f('0x1c')](_0x7e3f('0x1d'),close);}ami['on'](_0x7e3f('0x1e'),connect);ami['on'](_0x7e3f('0x1f'),function(_0x34294b){logger[_0x7e3f('0x1a')](util['format'](_0x7e3f('0x20'),config[_0x7e3f('0x7')][_0x7e3f('0x9')],config[_0x7e3f('0x7')]['ip'],config['asterisk'][_0x7e3f('0x8')],util[_0x7e3f('0xe')](_0x34294b,![],null)));});ami['on'](_0x7e3f('0x21'),function(_0x405838){logger['info'](util[_0x7e3f('0xf')](_0x7e3f('0x22'),config[_0x7e3f('0x7')][_0x7e3f('0x9')],config[_0x7e3f('0x7')]['ip'],config[_0x7e3f('0x7')]['port']));return BPromise[_0x7e3f('0x23')]()[_0x7e3f('0x24')](ami[_0x7e3f('0x11')]())[_0x7e3f('0x24')](ami[_0x7e3f('0x13')]())[_0x7e3f('0x24')](ami[_0x7e3f('0x25')]())[_0x7e3f('0x24')](ami[_0x7e3f('0x16')]())['then'](ami[_0x7e3f('0x18')]())['catch'](function(_0x1f6935){console['log'](_0x1f6935);});});ami[_0x7e3f('0x1c')](_0x7e3f('0xc'),error);ami[_0x7e3f('0x1c')](_0x7e3f('0x1d'),close);module[_0x7e3f('0x26')]=ami;