Built motion from commit f74363e9.|2.6.34
[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 _0x6bab=['exports','EventEmitter','ioredis','./error','redis','defaults','localhost','subscribe','agi','emit','error','E_AGI_SERVER_ERROR','parse'];(function(_0x399185,_0x4f9e21){var _0x1dffcb=function(_0x51fcec){while(--_0x51fcec){_0x399185['push'](_0x399185['shift']());}};_0x1dffcb(++_0x4f9e21);}(_0x6bab,0x1d5));var _0xb6ba=function(_0x39106e,_0x586f3d){_0x39106e=_0x39106e-0x0;var _0x892aec=_0x6bab[_0x39106e];return _0x892aec;};'use strict';var _=require('lodash');var EventEmitter=require('events')[_0xb6ba('0x0')];var Redis=require(_0xb6ba('0x1'));var AGIError=require(_0xb6ba('0x2'));var config=require('../../config/environment');config[_0xb6ba('0x3')]=_[_0xb6ba('0x4')](config['redis'],{'host':_0xb6ba('0x5'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0xb6ba('0x3')]);sub[_0xb6ba('0x6')](_0xb6ba('0x7'),function(_0x9fb83e){if(_0x9fb83e)return eventEmitter[_0xb6ba('0x8')](_0xb6ba('0x9'),new AGIError(_0xb6ba('0xa'),_0x9fb83e));});sub['on']('message',function(_0x3bf1fb,_0x1c0ee4){if(_0x3bf1fb!==_0xb6ba('0x7'))return;try{var _0x243dfb=JSON[_0xb6ba('0xb')](_0x1c0ee4);eventEmitter[_0xb6ba('0x8')]('projectUpdate',_0x243dfb);}catch(_0x320489){eventEmitter[_0xb6ba('0x8')]('error',new AGIError(_0xb6ba('0xa'),_0x320489));}});module[_0xb6ba('0xc')]={'EventEmitter':eventEmitter};