b2f10acdfcdb8e0e045395648614f38235b00e26
[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 _0xbc35=['subscribe','agi','emit','error','message','parse','projectUpdate','E_AGI_SERVER_ERROR','exports','lodash','events','EventEmitter','../../config/environment','redis','localhost'];(function(_0x52650d,_0x133d43){var _0x158c07=function(_0x3830d9){while(--_0x3830d9){_0x52650d['push'](_0x52650d['shift']());}};_0x158c07(++_0x133d43);}(_0xbc35,0x126));var _0x5bc3=function(_0x3eea7f,_0x244fb4){_0x3eea7f=_0x3eea7f-0x0;var _0x276117=_0xbc35[_0x3eea7f];return _0x276117;};'use strict';var _=require(_0x5bc3('0x0'));var EventEmitter=require(_0x5bc3('0x1'))[_0x5bc3('0x2')];var Redis=require('ioredis');var AGIError=require('./error');var config=require(_0x5bc3('0x3'));config[_0x5bc3('0x4')]=_['defaults'](config[_0x5bc3('0x4')],{'host':_0x5bc3('0x5'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config['redis']);sub[_0x5bc3('0x6')](_0x5bc3('0x7'),function(_0x126026){if(_0x126026)return eventEmitter[_0x5bc3('0x8')](_0x5bc3('0x9'),new AGIError('E_AGI_SERVER_ERROR',_0x126026));});sub['on'](_0x5bc3('0xa'),function(_0x1916a4,_0x3f6ead){if(_0x1916a4!=='agi')return;try{var _0x36291b=JSON[_0x5bc3('0xb')](_0x3f6ead);eventEmitter['emit'](_0x5bc3('0xc'),_0x36291b);}catch(_0x2a2ed4){eventEmitter[_0x5bc3('0x8')](_0x5bc3('0x9'),new AGIError(_0x5bc3('0xd'),_0x2a2ed4));}});module[_0x5bc3('0xe')]={'EventEmitter':eventEmitter};