Built motion from commit d5e4af8c.|2.6.23
[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 _0x68e5=['../../config/logger','asterisk','port','username','password','keepConnected','Action','promisify','action','error','format','sipshowregistry','actionDeviceStateList','devicestatelist','actionSipPeerStatus','sippeerstatus','actionQueueSummary','queuesummary','actionCoreShowChannels','coreshowchannels','Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s','once','connect','info','inspect','fullybooted','resolve','then','catch','[ami.js][fullybooted]','close','exports','asterisk-manager','util'];(function(_0x13ea6c,_0x5a8ae8){var _0x3c0b66=function(_0x22332d){while(--_0x22332d){_0x13ea6c['push'](_0x13ea6c['shift']());}};_0x3c0b66(++_0x5a8ae8);}(_0x68e5,0x86));var _0x568e=function(_0xa4e726,_0x415201){_0xa4e726=_0xa4e726-0x0;var _0x4cfe2f=_0x68e5[_0xa4e726];return _0x4cfe2f;};'use strict';var Manager=require(_0x568e('0x0'));var BPromise=require('bluebird');var util=require(_0x568e('0x1'));var logger=require(_0x568e('0x2'))('ami');var config=require('../../config/environment');var ami=new Manager(config[_0x568e('0x3')][_0x568e('0x4')],config['asterisk']['ip'],config['asterisk'][_0x568e('0x5')],config[_0x568e('0x3')][_0x568e('0x6')],!![]);ami[_0x568e('0x7')]();ami[_0x568e('0x8')]=BPromise[_0x568e('0x9')](ami[_0x568e('0xa')]);function error(_0x4668ef){logger[_0x568e('0xb')](util[_0x568e('0xc')]('Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s',config['asterisk'][_0x568e('0x5')],config[_0x568e('0x3')]['ip'],config[_0x568e('0x3')][_0x568e('0x4')],util['inspect'](_0x4668ef,![],null)));}function close(){logger[_0x568e('0xb')](util['format']('Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s',config[_0x568e('0x3')]['username'],config[_0x568e('0x3')]['ip'],config[_0x568e('0x3')][_0x568e('0x4')]));}ami['actionSipShowRegistry']=function(){return function(){return ami['Action']({'action':_0x568e('0xd')});};};ami[_0x568e('0xe')]=function(){return function(){return ami[_0x568e('0x8')]({'action':_0x568e('0xf')});};};ami[_0x568e('0x10')]=function(){return function(){return ami['Action']({'action':_0x568e('0x11')});};};ami[_0x568e('0x12')]=function(){return function(){return ami['Action']({'action':_0x568e('0x13')});};};ami[_0x568e('0x14')]=function(){return function(){return ami[_0x568e('0x8')]({'action':_0x568e('0x15')});};};function connect(){logger['info'](util[_0x568e('0xc')](_0x568e('0x16'),config['asterisk']['username'],config[_0x568e('0x3')]['ip'],config[_0x568e('0x3')][_0x568e('0x4')]));ami[_0x568e('0x17')]('error',error);ami[_0x568e('0x17')]('close',close);}ami['on'](_0x568e('0x18'),connect);ami['on']('shutdown',function(_0x175bbb){logger[_0x568e('0x19')](util[_0x568e('0xc')]('Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s',config[_0x568e('0x3')][_0x568e('0x5')],config[_0x568e('0x3')]['ip'],config[_0x568e('0x3')][_0x568e('0x4')],util[_0x568e('0x1a')](_0x175bbb,![],null)));});ami['on'](_0x568e('0x1b'),function(){logger[_0x568e('0x19')](util[_0x568e('0xc')]('Fullybooted\x20\x22%s\x22\x20to\x20%s:%s',config[_0x568e('0x3')][_0x568e('0x5')],config['asterisk']['ip'],config[_0x568e('0x3')]['port']));return Promise[_0x568e('0x1c')]()[_0x568e('0x1d')](ami['actionSipShowRegistry']())[_0x568e('0x1d')](ami[_0x568e('0xe')]())[_0x568e('0x1d')](ami['actionSipPeerStatus']())[_0x568e('0x1d')](ami[_0x568e('0x12')]())[_0x568e('0x1d')](ami[_0x568e('0x14')]())[_0x568e('0x1e')](function(_0x243c6f){logger['error'](_0x568e('0x1f'),util[_0x568e('0x1a')](_0x243c6f,{'showHidden':![],'depth':null}));});});ami[_0x568e('0x17')](_0x568e('0xb'),error);ami['once'](_0x568e('0x20'),close);module[_0x568e('0x21')]=ami;