c286af6da7d2e79d16b4af04a6780204a1bb0b9d
[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 _0xb9f5=['localhost','subscribe','emit','error','message','agi','parse','projectUpdate','E_AGI_SERVER_ERROR','lodash','events','EventEmitter','ioredis','./error','../../config/environment','defaults','redis'];(function(_0x5f382f,_0x3f1432){var _0x3bb11b=function(_0x4daf9b){while(--_0x4daf9b){_0x5f382f['push'](_0x5f382f['shift']());}};_0x3bb11b(++_0x3f1432);}(_0xb9f5,0x1a1));var _0x5b9f=function(_0x12a5ac,_0x4cb0d2){_0x12a5ac=_0x12a5ac-0x0;var _0x282958=_0xb9f5[_0x12a5ac];return _0x282958;};'use strict';var _=require(_0x5b9f('0x0'));var EventEmitter=require(_0x5b9f('0x1'))[_0x5b9f('0x2')];var Redis=require(_0x5b9f('0x3'));var AGIError=require(_0x5b9f('0x4'));var config=require(_0x5b9f('0x5'));config['redis']=_[_0x5b9f('0x6')](config[_0x5b9f('0x7')],{'host':_0x5b9f('0x8'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0x5b9f('0x7')]);sub[_0x5b9f('0x9')]('agi',function(_0x51e47e){if(_0x51e47e)return eventEmitter[_0x5b9f('0xa')](_0x5b9f('0xb'),new AGIError('E_AGI_SERVER_ERROR',_0x51e47e));});sub['on'](_0x5b9f('0xc'),function(_0x4b728b,_0x1f8b9d){if(_0x4b728b!==_0x5b9f('0xd'))return;try{var _0x32bf09=JSON[_0x5b9f('0xe')](_0x1f8b9d);eventEmitter[_0x5b9f('0xa')](_0x5b9f('0xf'),_0x32bf09);}catch(_0x7eac09){eventEmitter[_0x5b9f('0xa')]('error',new AGIError(_0x5b9f('0x10'),_0x7eac09));}});module['exports']={'EventEmitter':eventEmitter};