Built motion from commit 616d3211.|2.6.4
[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 _0x79be=['redis','defaults','localhost','subscribe','agi','error','E_AGI_SERVER_ERROR','message','parse','emit','exports','lodash','events','EventEmitter','./error'];(function(_0xafb127,_0x21d5db){var _0x5a6172=function(_0x10ad08){while(--_0x10ad08){_0xafb127['push'](_0xafb127['shift']());}};_0x5a6172(++_0x21d5db);}(_0x79be,0x1a0));var _0xe79b=function(_0x96590a,_0x12ae63){_0x96590a=_0x96590a-0x0;var _0x290d14=_0x79be[_0x96590a];return _0x290d14;};'use strict';var _=require(_0xe79b('0x0'));var EventEmitter=require(_0xe79b('0x1'))[_0xe79b('0x2')];var Redis=require('ioredis');var AGIError=require(_0xe79b('0x3'));var config=require('../../config/environment');config[_0xe79b('0x4')]=_[_0xe79b('0x5')](config[_0xe79b('0x4')],{'host':_0xe79b('0x6'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0xe79b('0x4')]);sub[_0xe79b('0x7')](_0xe79b('0x8'),function(_0x335eb5){if(_0x335eb5)return eventEmitter['emit'](_0xe79b('0x9'),new AGIError(_0xe79b('0xa'),_0x335eb5));});sub['on'](_0xe79b('0xb'),function(_0x5c9333,_0x1a6c80){if(_0x5c9333!==_0xe79b('0x8'))return;try{var _0x5156ec=JSON[_0xe79b('0xc')](_0x1a6c80);eventEmitter[_0xe79b('0xd')]('projectUpdate',_0x5156ec);}catch(_0x22f4ff){eventEmitter['emit']('error',new AGIError(_0xe79b('0xa'),_0x22f4ff));}});module[_0xe79b('0xe')]={'EventEmitter':eventEmitter};