9d7079c35b690e87da620f9447f7c4b87edf974a
[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 _0xe933=['error','E_AGI_SERVER_ERROR','message','parse','projectUpdate','exports','lodash','events','EventEmitter','ioredis','./error','redis','defaults','localhost','agi','emit'];(function(_0x496333,_0x1c47d6){var _0x44256e=function(_0x58767d){while(--_0x58767d){_0x496333['push'](_0x496333['shift']());}};_0x44256e(++_0x1c47d6);}(_0xe933,0x146));var _0x3e93=function(_0x27af45,_0x1b57aa){_0x27af45=_0x27af45-0x0;var _0x18df21=_0xe933[_0x27af45];return _0x18df21;};'use strict';var _=require(_0x3e93('0x0'));var EventEmitter=require(_0x3e93('0x1'))[_0x3e93('0x2')];var Redis=require(_0x3e93('0x3'));var AGIError=require(_0x3e93('0x4'));var config=require('../../config/environment');config[_0x3e93('0x5')]=_[_0x3e93('0x6')](config[_0x3e93('0x5')],{'host':_0x3e93('0x7'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0x3e93('0x5')]);sub['subscribe'](_0x3e93('0x8'),function(_0x59295c){if(_0x59295c)return eventEmitter[_0x3e93('0x9')](_0x3e93('0xa'),new AGIError(_0x3e93('0xb'),_0x59295c));});sub['on'](_0x3e93('0xc'),function(_0x4533dc,_0x160f29){if(_0x4533dc!==_0x3e93('0x8'))return;try{var _0x30b53c=JSON[_0x3e93('0xd')](_0x160f29);eventEmitter[_0x3e93('0x9')](_0x3e93('0xe'),_0x30b53c);}catch(_0x2e78b9){eventEmitter[_0x3e93('0x9')](_0x3e93('0xa'),new AGIError(_0x3e93('0xb'),_0x2e78b9));}});module[_0x3e93('0xf')]={'EventEmitter':eventEmitter};