165ddf272982091d929a83ee9934af243f5417ec
[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 _0xcae7=['localhost','subscribe','agi','error','message','parse','emit','E_AGI_SERVER_ERROR','exports','EventEmitter','ioredis','./error','../../config/environment','redis','defaults'];(function(_0x448ae2,_0x1676f5){var _0x4fdd34=function(_0x30e907){while(--_0x30e907){_0x448ae2['push'](_0x448ae2['shift']());}};_0x4fdd34(++_0x1676f5);}(_0xcae7,0xf9));var _0x7cae=function(_0x450689,_0x3b857c){_0x450689=_0x450689-0x0;var _0x46ffb0=_0xcae7[_0x450689];return _0x46ffb0;};'use strict';var _=require('lodash');var EventEmitter=require('events')[_0x7cae('0x0')];var Redis=require(_0x7cae('0x1'));var AGIError=require(_0x7cae('0x2'));var config=require(_0x7cae('0x3'));config[_0x7cae('0x4')]=_[_0x7cae('0x5')](config[_0x7cae('0x4')],{'host':_0x7cae('0x6'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0x7cae('0x4')]);sub[_0x7cae('0x7')](_0x7cae('0x8'),function(_0x3e51a7){if(_0x3e51a7)return eventEmitter['emit'](_0x7cae('0x9'),new AGIError('E_AGI_SERVER_ERROR',_0x3e51a7));});sub['on'](_0x7cae('0xa'),function(_0x2f2d2b,_0x59bc52){if(_0x2f2d2b!==_0x7cae('0x8'))return;try{var _0x1e2598=JSON[_0x7cae('0xb')](_0x59bc52);eventEmitter[_0x7cae('0xc')]('projectUpdate',_0x1e2598);}catch(_0x2f5092){eventEmitter[_0x7cae('0xc')]('error',new AGIError(_0x7cae('0xd'),_0x2f5092));}});module[_0x7cae('0xe')]={'EventEmitter':eventEmitter};