Built motion from commit (unavailable).|2.5.30
[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 _0x40be=['format','Manager\x20\x22%s\x22\x20error\x20to\x20%s:%s\x20with:\x0a%s','port','inspect','error','Manager\x20\x22%s\x22\x20closed\x20to\x20%s:%s','actionSipShowRegistry','sipshowregistry','actionDeviceStateList','devicestatelist','sippeerstatus','info','Manager\x20\x22%s\x22\x20logged\x20on\x20to\x20%s:%s','once','connect','fullybooted','then','catch','close','exports','moment','util','lodash','../../config/logger','../../config/environment','asterisk','username','password','keepConnected','Action','promisify'];(function(_0x2c7900,_0x44f3b6){var _0x35c02f=function(_0x343749){while(--_0x343749){_0x2c7900['push'](_0x2c7900['shift']());}};_0x35c02f(++_0x44f3b6);}(_0x40be,0x1e5));var _0xe40b=function(_0x338b7e,_0x2ab81a){_0x338b7e=_0x338b7e-0x0;var _0x8cb65=_0x40be[_0x338b7e];return _0x8cb65;};'use strict';var Manager=require('asterisk-manager');var BPromise=require('bluebird');var moment=require(_0xe40b('0x0'));var util=require(_0xe40b('0x1'));var _=require(_0xe40b('0x2'));var logger=require(_0xe40b('0x3'))('ami');var config=require(_0xe40b('0x4'));var ami=new Manager(config[_0xe40b('0x5')]['port'],config[_0xe40b('0x5')]['ip'],config[_0xe40b('0x5')][_0xe40b('0x6')],config[_0xe40b('0x5')][_0xe40b('0x7')],!![]);ami[_0xe40b('0x8')]();ami[_0xe40b('0x9')]=BPromise[_0xe40b('0xa')](ami['action']);function error(_0x2e5fc1){logger['error'](util[_0xe40b('0xb')](_0xe40b('0xc'),config[_0xe40b('0x5')]['username'],config[_0xe40b('0x5')]['ip'],config['asterisk'][_0xe40b('0xd')],util[_0xe40b('0xe')](_0x2e5fc1,![],null)));}function close(){logger[_0xe40b('0xf')](util[_0xe40b('0xb')](_0xe40b('0x10'),config[_0xe40b('0x5')]['username'],config[_0xe40b('0x5')]['ip'],config[_0xe40b('0x5')][_0xe40b('0xd')]));}ami[_0xe40b('0x11')]=function(){return function(){return ami[_0xe40b('0x9')]({'action':_0xe40b('0x12')});};};ami[_0xe40b('0x13')]=function(){return function(){return ami[_0xe40b('0x9')]({'action':_0xe40b('0x14')});};};ami['actionSipPeerStatus']=function(){return function(){return ami[_0xe40b('0x9')]({'action':_0xe40b('0x15')});};};ami['actionQueueSummary']=function(){return function(){return ami[_0xe40b('0x9')]({'action':'queuesummary'});};};ami['actionCoreShowChannels']=function(){return function(){return ami[_0xe40b('0x9')]({'action':'coreshowchannels'});};};function connect(_0xe6cf1b){logger[_0xe40b('0x16')](util[_0xe40b('0xb')](_0xe40b('0x17'),config[_0xe40b('0x5')][_0xe40b('0x6')],config['asterisk']['ip'],config[_0xe40b('0x5')][_0xe40b('0xd')]));ami[_0xe40b('0x18')](_0xe40b('0xf'),error);ami['once']('close',close);}ami['on'](_0xe40b('0x19'),connect);ami['on']('shutdown',function(_0x1832d7){logger[_0xe40b('0x16')](util[_0xe40b('0xb')]('Shutdown\x20\x22%s\x22\x20to\x20%s:%s\x20with:\x0a%s',config[_0xe40b('0x5')]['username'],config[_0xe40b('0x5')]['ip'],config[_0xe40b('0x5')][_0xe40b('0xd')],util[_0xe40b('0xe')](_0x1832d7,![],null)));});ami['on'](_0xe40b('0x1a'),function(_0x5c0ec4){logger[_0xe40b('0x16')](util[_0xe40b('0xb')]('Fullybooted\x20\x22%s\x22\x20to\x20%s:%s',config[_0xe40b('0x5')]['username'],config[_0xe40b('0x5')]['ip'],config[_0xe40b('0x5')][_0xe40b('0xd')]));return BPromise['resolve']()[_0xe40b('0x1b')](ami[_0xe40b('0x11')]())[_0xe40b('0x1b')](ami[_0xe40b('0x13')]())[_0xe40b('0x1b')](ami['actionSipPeerStatus']())[_0xe40b('0x1b')](ami['actionQueueSummary']())[_0xe40b('0x1b')](ami['actionCoreShowChannels']())[_0xe40b('0x1c')](function(_0x4de769){console['log'](_0x4de769);});});ami['once'](_0xe40b('0xf'),error);ami['once'](_0xe40b('0x1d'),close);module[_0xe40b('0x1e')]=ami;