Built motion from commit 1fa89557.|2.6.10
[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 _0x1ff8=['exports','events','EventEmitter','redis','defaults','localhost','subscribe','emit','error','E_AGI_SERVER_ERROR','message','agi','projectUpdate'];(function(_0x3e87c9,_0x3c9cce){var _0x1b340a=function(_0x3c3fca){while(--_0x3c3fca){_0x3e87c9['push'](_0x3e87c9['shift']());}};_0x1b340a(++_0x3c9cce);}(_0x1ff8,0x76));var _0x81ff=function(_0xea950a,_0x12fa9e){_0xea950a=_0xea950a-0x0;var _0x134c5f=_0x1ff8[_0xea950a];return _0x134c5f;};'use strict';var _=require('lodash');var EventEmitter=require(_0x81ff('0x0'))[_0x81ff('0x1')];var Redis=require('ioredis');var AGIError=require('./error');var config=require('../../config/environment');config[_0x81ff('0x2')]=_[_0x81ff('0x3')](config[_0x81ff('0x2')],{'host':_0x81ff('0x4'),'port':0x18eb});var eventEmitter=new EventEmitter();var sub=new Redis(config[_0x81ff('0x2')]);sub[_0x81ff('0x5')]('agi',function(_0x2a6ef3){if(_0x2a6ef3)return eventEmitter[_0x81ff('0x6')](_0x81ff('0x7'),new AGIError(_0x81ff('0x8'),_0x2a6ef3));});sub['on'](_0x81ff('0x9'),function(_0x5bd9ba,_0x3cbfcf){if(_0x5bd9ba!==_0x81ff('0xa'))return;try{var _0x2869ef=JSON['parse'](_0x3cbfcf);eventEmitter['emit'](_0x81ff('0xb'),_0x2869ef);}catch(_0x255ebf){eventEmitter[_0x81ff('0x6')]('error',new AGIError(_0x81ff('0x8'),_0x255ebf));}});module[_0x81ff('0xc')]={'EventEmitter':eventEmitter};