d827d9013f4be934371eb10ed12422964c46e4e7
[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 _0xed7c=['projectUpdate','E_AGI_SERVER_ERROR','exports','lodash','events','EventEmitter','./error','../../config/environment','redis','localhost','subscribe','agi','emit','error','parse'];(function(_0x597eab,_0xba46ae){var _0x51c2ca=function(_0x3f55ba){while(--_0x3f55ba){_0x597eab['push'](_0x597eab['shift']());}};_0x51c2ca(++_0xba46ae);}(_0xed7c,0x7b));var _0xced7=function(_0x53359b,_0x5f30f6){_0x53359b=_0x53359b-0x0;var _0x1d3171=_0xed7c[_0x53359b];return _0x1d3171;};'use strict';var _=require(_0xced7('0x0'));var EventEmitter=require(_0xced7('0x1'))[_0xced7('0x2')];var Redis=require('ioredis');var AGIError=require(_0xced7('0x3'));var config=require(_0xced7('0x4'));config[_0xced7('0x5')]=_['defaults'](config['redis'],{'host':_0xced7('0x6'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config['redis']);sub[_0xced7('0x7')](_0xced7('0x8'),function(_0x537b09){if(_0x537b09)return eventEmitter[_0xced7('0x9')](_0xced7('0xa'),new AGIError('E_AGI_SERVER_ERROR',_0x537b09));});sub['on']('message',function(_0x31fefe,_0x1484d2){if(_0x31fefe!==_0xced7('0x8'))return;try{var _0x5e0cac=JSON[_0xced7('0xb')](_0x1484d2);eventEmitter['emit'](_0xced7('0xc'),_0x5e0cac);}catch(_0x10a66e){eventEmitter[_0xced7('0x9')]('error',new AGIError(_0xced7('0xd'),_0x10a66e));}});module[_0xced7('0xe')]={'EventEmitter':eventEmitter};