Built motion from commit (unavailable).|2.5.21
[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 _0xed50=['bluebird','moment','util','lodash','../../config/logger','ami','../../config/environment','asterisk','port','password','keepConnected','Action','promisify','action','error','Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s','username','inspect','format','actionSipShowRegistry','sipshowregistry','actionDeviceStateList','devicestatelist','sippeerstatus','actionQueueSummary','queuesummary','actionCoreShowChannels','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','resolve','then','actionSipPeerStatus','catch','asterisk-manager'];(function(_0x51cd26,_0xf2e5f3){var _0x9cfab7=function(_0x40e76e){while(--_0x40e76e){_0x51cd26['push'](_0x51cd26['shift']());}};_0x9cfab7(++_0xf2e5f3);}(_0xed50,0x74));var _0x0ed5=function(_0x32c48c,_0x5d669e){_0x32c48c=_0x32c48c-0x0;var _0x133729=_0xed50[_0x32c48c];return _0x133729;};'use strict';var Manager=require(_0x0ed5('0x0'));var BPromise=require(_0x0ed5('0x1'));var moment=require(_0x0ed5('0x2'));var util=require(_0x0ed5('0x3'));var _=require(_0x0ed5('0x4'));var logger=require(_0x0ed5('0x5'))(_0x0ed5('0x6'));var config=require(_0x0ed5('0x7'));var ami=new Manager(config[_0x0ed5('0x8')][_0x0ed5('0x9')],config['asterisk']['ip'],config['asterisk']['username'],config[_0x0ed5('0x8')][_0x0ed5('0xa')],!![]);ami[_0x0ed5('0xb')]();ami[_0x0ed5('0xc')]=BPromise[_0x0ed5('0xd')](ami[_0x0ed5('0xe')]);function error(_0xe0ddb){logger[_0x0ed5('0xf')](util['format'](_0x0ed5('0x10'),config[_0x0ed5('0x8')][_0x0ed5('0x11')],config[_0x0ed5('0x8')]['ip'],config[_0x0ed5('0x8')]['port'],util[_0x0ed5('0x12')](_0xe0ddb,![],null)));}function close(){logger[_0x0ed5('0xf')](util[_0x0ed5('0x13')]('Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s',config['asterisk'][_0x0ed5('0x11')],config[_0x0ed5('0x8')]['ip'],config[_0x0ed5('0x8')]['port']));}ami[_0x0ed5('0x14')]=function(){return function(){return ami[_0x0ed5('0xc')]({'action':_0x0ed5('0x15')});};};ami[_0x0ed5('0x16')]=function(){return function(){return ami[_0x0ed5('0xc')]({'action':_0x0ed5('0x17')});};};ami['actionSipPeerStatus']=function(){return function(){return ami['Action']({'action':_0x0ed5('0x18')});};};ami[_0x0ed5('0x19')]=function(){return function(){return ami['Action']({'action':_0x0ed5('0x1a')});};};ami[_0x0ed5('0x1b')]=function(){return function(){return ami['Action']({'action':'coreshowchannels'});};};function connect(_0x4241b6){logger[_0x0ed5('0x1c')](util[_0x0ed5('0x13')](_0x0ed5('0x1d'),config['asterisk'][_0x0ed5('0x11')],config[_0x0ed5('0x8')]['ip'],config[_0x0ed5('0x8')][_0x0ed5('0x9')]));ami[_0x0ed5('0x1e')](_0x0ed5('0xf'),error);ami['once'](_0x0ed5('0x1f'),close);}ami['on'](_0x0ed5('0x20'),connect);ami['on'](_0x0ed5('0x21'),function(_0x578310){logger[_0x0ed5('0x1c')](util[_0x0ed5('0x13')](_0x0ed5('0x22'),config[_0x0ed5('0x8')][_0x0ed5('0x11')],config['asterisk']['ip'],config[_0x0ed5('0x8')][_0x0ed5('0x9')],util[_0x0ed5('0x12')](_0x578310,![],null)));});ami['on']('fullybooted',function(_0x538675){logger[_0x0ed5('0x1c')](util['format']('Fullybooted\x20\x22%s\x22\x20to\x20%s:%s',config[_0x0ed5('0x8')]['username'],config[_0x0ed5('0x8')]['ip'],config[_0x0ed5('0x8')][_0x0ed5('0x9')]));return BPromise[_0x0ed5('0x23')]()[_0x0ed5('0x24')](ami[_0x0ed5('0x14')]())[_0x0ed5('0x24')](ami[_0x0ed5('0x16')]())[_0x0ed5('0x24')](ami[_0x0ed5('0x25')]())[_0x0ed5('0x24')](ami[_0x0ed5('0x19')]())[_0x0ed5('0x24')](ami[_0x0ed5('0x1b')]())[_0x0ed5('0x26')](function(_0x313970){console['log'](_0x313970);});});ami[_0x0ed5('0x1e')](_0x0ed5('0xf'),error);ami[_0x0ed5('0x1e')]('close',close);module['exports']=ami;