Built motion from commit e0fa946e.|2.6.5
[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 _0xce93=['emit','error','E_AGI_SERVER_ERROR','message','agi','projectUpdate','exports','lodash','events','EventEmitter','ioredis','localhost','redis','subscribe'];(function(_0x5aa8f9,_0x55a176){var _0x9fed8a=function(_0x56a0f3){while(--_0x56a0f3){_0x5aa8f9['push'](_0x5aa8f9['shift']());}};_0x9fed8a(++_0x55a176);}(_0xce93,0xf5));var _0x3ce9=function(_0x469add,_0x50ef21){_0x469add=_0x469add-0x0;var _0x2e8a26=_0xce93[_0x469add];return _0x2e8a26;};'use strict';var _=require(_0x3ce9('0x0'));var EventEmitter=require(_0x3ce9('0x1'))[_0x3ce9('0x2')];var Redis=require(_0x3ce9('0x3'));var AGIError=require('./error');var config=require('../../config/environment');config['redis']=_['defaults'](config['redis'],{'host':_0x3ce9('0x4'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0x3ce9('0x5')]);sub[_0x3ce9('0x6')]('agi',function(_0x410d5e){if(_0x410d5e)return eventEmitter[_0x3ce9('0x7')](_0x3ce9('0x8'),new AGIError(_0x3ce9('0x9'),_0x410d5e));});sub['on'](_0x3ce9('0xa'),function(_0x2a1078,_0x30c476){if(_0x2a1078!==_0x3ce9('0xb'))return;try{var _0x367fa4=JSON['parse'](_0x30c476);eventEmitter[_0x3ce9('0x7')](_0x3ce9('0xc'),_0x367fa4);}catch(_0x2966c0){eventEmitter[_0x3ce9('0x7')](_0x3ce9('0x8'),new AGIError('E_AGI_SERVER_ERROR',_0x2966c0));}});module[_0x3ce9('0xd')]={'EventEmitter':eventEmitter};