Built motion from commit d9028345.|2.5.43
[motion2.git] / server / services / routing / server / applications / strategy / rrmemory.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 _0x4d4e=['[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','hideNotification','TIMEOUT','busy','exports','lodash','uuid','routing','squeue','queue','realtime','intervals','push','handleRun','bind','handleTimeout','timeout','drained','handleDrained','prototype','isAgentAvailable','agents','info','agentId','done','[%s][QUEUE]\x20try\x20with\x20%s','isNil','busyQueue','name','showNotification','notificationId','writeLog','RINGING','handleCheckReject'];(function(_0x48dce5,_0x13b5ac){var _0x1f9e17=function(_0x21141a){while(--_0x21141a){_0x48dce5['push'](_0x48dce5['shift']());}};_0x1f9e17(++_0x13b5ac);}(_0x4d4e,0x92));var _0xe4d4=function(_0x56e2ed,_0x1c4781){_0x56e2ed=_0x56e2ed-0x0;var _0x5237b2=_0x4d4e[_0x56e2ed];return _0x5237b2;};'use strict';var rr=require('rr');var _=require(_0xe4d4('0x0'));var uuid=require(_0xe4d4('0x1'));var util=require('./util');var logger=require('../../../../../config/logger')(_0xe4d4('0x2'));var RRMemory=function(_0x5ac226,_0x2356d3,_0x449470,_0x1c4906){this['notificationId']=uuid['v4']();this[_0xe4d4('0x3')]=_0x5ac226;this[_0xe4d4('0x4')]=_0x2356d3;this[_0xe4d4('0x5')]=_0x449470;this['routing']=_0x1c4906;this[_0xe4d4('0x6')]={};this[_0xe4d4('0x3')][_0xe4d4('0x7')](this[_0xe4d4('0x8')][_0xe4d4('0x9')](this),this[_0xe4d4('0xa')][_0xe4d4('0x9')](this),this['module']);this[_0xe4d4('0x3')]['on'](_0xe4d4('0xb'),this['handleTimeout']['bind'](this));this[_0xe4d4('0x3')]['on'](_0xe4d4('0xc'),this[_0xe4d4('0xd')][_0xe4d4('0x9')](this));};RRMemory[_0xe4d4('0xe')][_0xe4d4('0x7')]=function(){this[_0xe4d4('0x3')][_0xe4d4('0x7')](this[_0xe4d4('0x8')]['bind'](this),this['handleTimeout']['bind'](this));};RRMemory[_0xe4d4('0xe')][_0xe4d4('0xd')]=function(_0x4ea660){this[_0xe4d4('0xa')](!![]);};RRMemory[_0xe4d4('0xe')]['handleCheckReject']=function(_0x2fdcbe){if(util[_0xe4d4('0xf')](this[_0xe4d4('0x3')]['id'],this[_0xe4d4('0x5')][_0xe4d4('0x10')][this['agentId']],this[_0xe4d4('0x3')]['channel'],!![])){logger[_0xe4d4('0x11')]('[%s][QUEUE]\x20available\x20again\x20%s',this[_0xe4d4('0x3')]['id'],this['agentId']);clearInterval(this[_0xe4d4('0x6')][this[_0xe4d4('0x12')]]);_0x2fdcbe[_0xe4d4('0x13')]();setTimeout(this[_0xe4d4('0x7')][_0xe4d4('0x9')](this),0x3e8);}};RRMemory['prototype'][_0xe4d4('0x8')]=function(_0x2f40b7){this[_0xe4d4('0x12')]=rr(this[_0xe4d4('0x4')]['mapAgentsId']);logger[_0xe4d4('0x11')](_0xe4d4('0x14'),this[_0xe4d4('0x3')]['id'],this[_0xe4d4('0x12')]);if(_[_0xe4d4('0x15')](this[_0xe4d4('0x5')][_0xe4d4('0x10')][this[_0xe4d4('0x12')]])){logger[_0xe4d4('0x11')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0xe4d4('0x3')]['id'],this[_0xe4d4('0x12')]);_0x2f40b7['done']();setTimeout(this[_0xe4d4('0x7')][_0xe4d4('0x9')](this),0x3e8);}else{if(util[_0xe4d4('0xf')](this[_0xe4d4('0x3')]['id'],this[_0xe4d4('0x5')][_0xe4d4('0x10')][this['agentId']],this[_0xe4d4('0x3')]['channel'],!![])){this[_0xe4d4('0x5')][_0xe4d4('0x10')][this[_0xe4d4('0x12')]]['busy']=!![];this[_0xe4d4('0x5')][_0xe4d4('0x10')][this['agentId']][_0xe4d4('0x16')]=this[_0xe4d4('0x4')][_0xe4d4('0x17')];util[_0xe4d4('0x18')](this[_0xe4d4('0x19')],this[_0xe4d4('0x3')]['id'],this[_0xe4d4('0x5')][_0xe4d4('0x10')][this[_0xe4d4('0x12')]],this['queue'],this[_0xe4d4('0x2')]);util[_0xe4d4('0x1a')](this[_0xe4d4('0x3')]['id'],this[_0xe4d4('0x5')][_0xe4d4('0x10')][this[_0xe4d4('0x12')]],_0xe4d4('0x1b'));this['intervals'][this['agentId']]=setInterval(this[_0xe4d4('0x1c')][_0xe4d4('0x9')](this,_0x2f40b7),0x3e8);}else{logger[_0xe4d4('0x11')](_0xe4d4('0x1d'),this[_0xe4d4('0x3')]['id'],this[_0xe4d4('0x12')]);_0x2f40b7[_0xe4d4('0x13')]();setTimeout(this[_0xe4d4('0x7')][_0xe4d4('0x9')](this),0x3e8);}}};RRMemory[_0xe4d4('0xe')][_0xe4d4('0xa')]=function(_0x656b4d){logger[_0xe4d4('0x11')]('[%s][QUEUE]\x20timeout\x20with\x20%s',this[_0xe4d4('0x3')]['id'],this[_0xe4d4('0x12')]);if(_[_0xe4d4('0x15')](this[_0xe4d4('0x5')]['agents'][this[_0xe4d4('0x12')]])){logger['info'](_0xe4d4('0x1e'),this['squeue']['id'],this['agentId']);}else{clearInterval(this[_0xe4d4('0x6')][this[_0xe4d4('0x12')]]);util[_0xe4d4('0x1f')](this[_0xe4d4('0x19')],this[_0xe4d4('0x3')]['id'],this[_0xe4d4('0x5')][_0xe4d4('0x10')][this[_0xe4d4('0x12')]],this[_0xe4d4('0x4')],this[_0xe4d4('0x2')]);util[_0xe4d4('0x1a')](this[_0xe4d4('0x3')]['id'],this[_0xe4d4('0x5')][_0xe4d4('0x10')][this[_0xe4d4('0x12')]],_0xe4d4('0x20'));this['realtime']['agents'][this[_0xe4d4('0x12')]][_0xe4d4('0x21')]=![];this[_0xe4d4('0x5')][_0xe4d4('0x10')][this[_0xe4d4('0x12')]]['busyQueue']=undefined;}if(!_0x656b4d){setTimeout(this[_0xe4d4('0x7')][_0xe4d4('0x9')](this),0x3e8);}};function rrmemory(_0xf1d601,_0x17eabf,_0x523128,_0x5e63ce){return new RRMemory(_0xf1d601,_0x17eabf,_0x523128,_0x5e63ce);}module[_0xe4d4('0x22')]=rrmemory;