28a29de64377ef802f40af5a010b9e4034911c7a
[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 _0x07a2=['defaults','localhost','subscribe','agi','error','E_AGI_SERVER_ERROR','projectUpdate','exports','lodash','events','ioredis','./error','../../config/environment','redis'];(function(_0x14fda1,_0x5e8ab1){var _0x3bade2=function(_0x55b821){while(--_0x55b821){_0x14fda1['push'](_0x14fda1['shift']());}};_0x3bade2(++_0x5e8ab1);}(_0x07a2,0x166));var _0x207a=function(_0x218994,_0x2cf487){_0x218994=_0x218994-0x0;var _0x3f350b=_0x07a2[_0x218994];return _0x3f350b;};'use strict';var _=require(_0x207a('0x0'));var EventEmitter=require(_0x207a('0x1'))['EventEmitter'];var Redis=require(_0x207a('0x2'));var AGIError=require(_0x207a('0x3'));var config=require(_0x207a('0x4'));config[_0x207a('0x5')]=_[_0x207a('0x6')](config[_0x207a('0x5')],{'host':_0x207a('0x7'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config['redis']);sub[_0x207a('0x8')](_0x207a('0x9'),function(_0x5eb658){if(_0x5eb658)return eventEmitter['emit'](_0x207a('0xa'),new AGIError(_0x207a('0xb'),_0x5eb658));});sub['on']('message',function(_0x3bd6b3,_0x440137){if(_0x3bd6b3!==_0x207a('0x9'))return;try{var _0x52b764=JSON['parse'](_0x440137);eventEmitter['emit'](_0x207a('0xc'),_0x52b764);}catch(_0x27f8ba){eventEmitter['emit']('error',new AGIError('E_AGI_SERVER_ERROR',_0x27f8ba));}});module[_0x207a('0xd')]={'EventEmitter':eventEmitter};