Built motion from commit ff426b3f.|2.6.29
[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 _0x7b00=['projectUpdate','exports','events','../../config/environment','redis','subscribe','agi','E_AGI_SERVER_ERROR','parse','emit'];(function(_0x5b7c48,_0x51cc75){var _0x281824=function(_0x394f64){while(--_0x394f64){_0x5b7c48['push'](_0x5b7c48['shift']());}};_0x281824(++_0x51cc75);}(_0x7b00,0x160));var _0x07b0=function(_0x2c8e83,_0x272b88){_0x2c8e83=_0x2c8e83-0x0;var _0x28696e=_0x7b00[_0x2c8e83];return _0x28696e;};'use strict';var _=require('lodash');var EventEmitter=require(_0x07b0('0x0'))['EventEmitter'];var Redis=require('ioredis');var AGIError=require('./error');var config=require(_0x07b0('0x1'));config[_0x07b0('0x2')]=_['defaults'](config[_0x07b0('0x2')],{'host':'localhost','port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0x07b0('0x2')]);sub[_0x07b0('0x3')](_0x07b0('0x4'),function(_0xabf1c2){if(_0xabf1c2)return eventEmitter['emit']('error',new AGIError(_0x07b0('0x5'),_0xabf1c2));});sub['on']('message',function(_0x1853f3,_0x3ec50d){if(_0x1853f3!=='agi')return;try{var _0x906741=JSON[_0x07b0('0x6')](_0x3ec50d);eventEmitter[_0x07b0('0x7')](_0x07b0('0x8'),_0x906741);}catch(_0x93aab3){eventEmitter['emit']('error',new AGIError(_0x07b0('0x5'),_0x93aab3));}});module[_0x07b0('0x9')]={'EventEmitter':eventEmitter};