Built motion from commit d301b742.|2.6.29
[motion2.git] / server / services / agi / events.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 _0x2589=['redis','localhost','subscribe','agi','emit','error','E_AGI_SERVER_ERROR','message','parse','projectUpdate','lodash','events','EventEmitter','ioredis','./error','../../config/environment'];(function(_0x53ed50,_0x25a004){var _0x391967=function(_0x5258c1){while(--_0x5258c1){_0x53ed50['push'](_0x53ed50['shift']());}};_0x391967(++_0x25a004);}(_0x2589,0x1ea));var _0x9258=function(_0x5aa87f,_0x13bffb){_0x5aa87f=_0x5aa87f-0x0;var _0x16d679=_0x2589[_0x5aa87f];return _0x16d679;};'use strict';var _=require(_0x9258('0x0'));var EventEmitter=require(_0x9258('0x1'))[_0x9258('0x2')];var Redis=require(_0x9258('0x3'));var AGIError=require(_0x9258('0x4'));var config=require(_0x9258('0x5'));config[_0x9258('0x6')]=_['defaults'](config['redis'],{'host':_0x9258('0x7'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0x9258('0x6')]);sub[_0x9258('0x8')](_0x9258('0x9'),function(_0x17d0b5){if(_0x17d0b5)return eventEmitter[_0x9258('0xa')](_0x9258('0xb'),new AGIError(_0x9258('0xc'),_0x17d0b5));});sub['on'](_0x9258('0xd'),function(_0x165b6f,_0x5f479a){if(_0x165b6f!==_0x9258('0x9'))return;try{var _0x1eabd4=JSON[_0x9258('0xe')](_0x5f479a);eventEmitter[_0x9258('0xa')](_0x9258('0xf'),_0x1eabd4);}catch(_0x12963d){eventEmitter[_0x9258('0xa')]('error',new AGIError(_0x9258('0xc'),_0x12963d));}});module['exports']={'EventEmitter':eventEmitter};