Built motion from commit (unavailable).|2.5.7
[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 _0xff1c=['Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s','once','close','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','log','exports','bluebird','moment','lodash','../../config/logger','ami','../../config/environment','asterisk','port','username','password','keepConnected','Action','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','devicestatelist','actionSipPeerStatus','sippeerstatus','actionQueueSummary','coreshowchannels','info'];(function(_0x540d4f,_0x2713b6){var _0x48f007=function(_0x3ff096){while(--_0x3ff096){_0x540d4f['push'](_0x540d4f['shift']());}};_0x48f007(++_0x2713b6);}(_0xff1c,0x13b));var _0xcff1=function(_0x1ff149,_0x3c9fff){_0x1ff149=_0x1ff149-0x0;var _0x28e8ca=_0xff1c[_0x1ff149];return _0x28e8ca;};'use strict';var Manager=require('asterisk-manager');var BPromise=require(_0xcff1('0x0'));var moment=require(_0xcff1('0x1'));var util=require('util');var _=require(_0xcff1('0x2'));var logger=require(_0xcff1('0x3'))(_0xcff1('0x4'));var config=require(_0xcff1('0x5'));var ami=new Manager(config[_0xcff1('0x6')][_0xcff1('0x7')],config['asterisk']['ip'],config[_0xcff1('0x6')][_0xcff1('0x8')],config[_0xcff1('0x6')][_0xcff1('0x9')],!![]);ami[_0xcff1('0xa')]();ami[_0xcff1('0xb')]=BPromise[_0xcff1('0xc')](ami['action']);function error(_0x35ef24){logger[_0xcff1('0xd')](util['format'](_0xcff1('0xe'),config['asterisk']['username'],config['asterisk']['ip'],config[_0xcff1('0x6')][_0xcff1('0x7')],util[_0xcff1('0xf')](_0x35ef24,![],null)));}function close(){logger[_0xcff1('0xd')](util[_0xcff1('0x10')](_0xcff1('0x11'),config[_0xcff1('0x6')][_0xcff1('0x8')],config['asterisk']['ip'],config['asterisk'][_0xcff1('0x7')]));}ami[_0xcff1('0x12')]=function(){return function(){return ami[_0xcff1('0xb')]({'action':_0xcff1('0x13')});};};ami[_0xcff1('0x14')]=function(){return function(){return ami[_0xcff1('0xb')]({'action':_0xcff1('0x15')});};};ami[_0xcff1('0x16')]=function(){return function(){return ami[_0xcff1('0xb')]({'action':_0xcff1('0x17')});};};ami[_0xcff1('0x18')]=function(){return function(){return ami[_0xcff1('0xb')]({'action':'queuesummary'});};};ami['actionCoreShowChannels']=function(){return function(){return ami[_0xcff1('0xb')]({'action':_0xcff1('0x19')});};};function connect(_0x5e9ef9){logger[_0xcff1('0x1a')](util[_0xcff1('0x10')](_0xcff1('0x1b'),config[_0xcff1('0x6')][_0xcff1('0x8')],config[_0xcff1('0x6')]['ip'],config['asterisk'][_0xcff1('0x7')]));ami[_0xcff1('0x1c')]('error',error);ami[_0xcff1('0x1c')](_0xcff1('0x1d'),close);}ami['on']('connect',connect);ami['on'](_0xcff1('0x1e'),function(_0x52b391){logger['info'](util[_0xcff1('0x10')](_0xcff1('0x1f'),config[_0xcff1('0x6')][_0xcff1('0x8')],config[_0xcff1('0x6')]['ip'],config[_0xcff1('0x6')]['port'],util[_0xcff1('0xf')](_0x52b391,![],null)));});ami['on'](_0xcff1('0x20'),function(_0x516123){logger[_0xcff1('0x1a')](util['format'](_0xcff1('0x21'),config[_0xcff1('0x6')][_0xcff1('0x8')],config[_0xcff1('0x6')]['ip'],config[_0xcff1('0x6')][_0xcff1('0x7')]));return BPromise[_0xcff1('0x22')]()[_0xcff1('0x23')](ami[_0xcff1('0x12')]())[_0xcff1('0x23')](ami[_0xcff1('0x14')]())[_0xcff1('0x23')](ami[_0xcff1('0x16')]())[_0xcff1('0x23')](ami[_0xcff1('0x18')]())[_0xcff1('0x23')](ami['actionCoreShowChannels']())['catch'](function(_0x4bc289){console[_0xcff1('0x24')](_0x4bc289);});});ami[_0xcff1('0x1c')](_0xcff1('0xd'),error);ami[_0xcff1('0x1c')](_0xcff1('0x1d'),close);module[_0xcff1('0x25')]=ami;