7c332d76b21781644caa161c11220f730a08772c
[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 _0x3478=['projectUpdate','E_AGI_SERVER_ERROR','events','ioredis','./error','../../config/environment','redis','defaults','localhost','subscribe','agi','emit','error','message','parse'];(function(_0xa8f7f7,_0x10f3f5){var _0x5e5be3=function(_0x5730ab){while(--_0x5730ab){_0xa8f7f7['push'](_0xa8f7f7['shift']());}};_0x5e5be3(++_0x10f3f5);}(_0x3478,0xe3));var _0x8347=function(_0x4d77b8,_0x208e64){_0x4d77b8=_0x4d77b8-0x0;var _0x82da62=_0x3478[_0x4d77b8];return _0x82da62;};'use strict';var _=require('lodash');var EventEmitter=require(_0x8347('0x0'))['EventEmitter'];var Redis=require(_0x8347('0x1'));var AGIError=require(_0x8347('0x2'));var config=require(_0x8347('0x3'));config[_0x8347('0x4')]=_[_0x8347('0x5')](config['redis'],{'host':_0x8347('0x6'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0x8347('0x4')]);sub[_0x8347('0x7')](_0x8347('0x8'),function(_0x4e4be6){if(_0x4e4be6)return eventEmitter[_0x8347('0x9')](_0x8347('0xa'),new AGIError('E_AGI_SERVER_ERROR',_0x4e4be6));});sub['on'](_0x8347('0xb'),function(_0xfe8b6c,_0xf93eb9){if(_0xfe8b6c!==_0x8347('0x8'))return;try{var _0x3f9e73=JSON[_0x8347('0xc')](_0xf93eb9);eventEmitter['emit'](_0x8347('0xd'),_0x3f9e73);}catch(_0x359524){eventEmitter[_0x8347('0x9')]('error',new AGIError(_0x8347('0xe'),_0x359524));}});module['exports']={'EventEmitter':eventEmitter};