Built motion from commit 10af8726.|2.6.34
[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 _0x6a6a=['name','showNotification','RINGING','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','writeLog','removeWaitingNotification','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','intervals','push','bind','handleTimeout','module','timeout','drained','prototype','handleCheckReject','isAgentAvailable','realtime','agents','agentId','channel','debug','done','handleRun','mapAgentsId','[%s][QUEUE]\x20try\x20with\x20%s','isNil','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','busy','busyQueue'];(function(_0x7954b0,_0x529b8c){var _0x5caf75=function(_0x356fe4){while(--_0x356fe4){_0x7954b0['push'](_0x7954b0['shift']());}};_0x5caf75(++_0x529b8c);}(_0x6a6a,0x183));var _0xa6a6=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x6a6a[_0x14add3];return _0x4a174f;};'use strict';var rr=require('rr');var _=require(_0xa6a6('0x0'));var uuid=require(_0xa6a6('0x1'));var util=require(_0xa6a6('0x2'));var logger=require(_0xa6a6('0x3'))(_0xa6a6('0x4'));var RRMemory=function(_0xa3935c,_0x1f9ad4,_0xe22b33,_0x33e449){this[_0xa6a6('0x5')]=uuid['v4']();this[_0xa6a6('0x6')]=_0xa3935c;this[_0xa6a6('0x7')]=_0x1f9ad4;this['realtime']=_0xe22b33;this[_0xa6a6('0x4')]=_0x33e449;this[_0xa6a6('0x8')]={};this[_0xa6a6('0x6')][_0xa6a6('0x9')](this['handleRun'][_0xa6a6('0xa')](this),this[_0xa6a6('0xb')]['bind'](this),this[_0xa6a6('0xc')]);this[_0xa6a6('0x6')]['on'](_0xa6a6('0xd'),this[_0xa6a6('0xb')][_0xa6a6('0xa')](this));this[_0xa6a6('0x6')]['on'](_0xa6a6('0xe'),this['handleDrained'][_0xa6a6('0xa')](this));};RRMemory['prototype']['push']=function(){this[_0xa6a6('0x6')]['push'](this['handleRun'][_0xa6a6('0xa')](this),this[_0xa6a6('0xb')][_0xa6a6('0xa')](this));};RRMemory['prototype']['handleDrained']=function(){this[_0xa6a6('0xb')](!![]);};RRMemory[_0xa6a6('0xf')][_0xa6a6('0x10')]=function(_0x2bf57f){if(util[_0xa6a6('0x11')](this['squeue']['id'],this[_0xa6a6('0x12')][_0xa6a6('0x13')][this[_0xa6a6('0x14')]],this[_0xa6a6('0x6')][_0xa6a6('0x15')],!![])){logger[_0xa6a6('0x16')]('[%s][QUEUE]\x20available\x20again\x20%s',this[_0xa6a6('0x6')]['id'],this['agentId']);clearInterval(this['intervals'][this[_0xa6a6('0x14')]]);_0x2bf57f[_0xa6a6('0x17')]();setTimeout(this[_0xa6a6('0x9')][_0xa6a6('0xa')](this),0x3e8);}};RRMemory[_0xa6a6('0xf')][_0xa6a6('0x18')]=function(_0x269083){this[_0xa6a6('0x14')]=rr(this['queue'][_0xa6a6('0x19')]);logger[_0xa6a6('0x16')](_0xa6a6('0x1a'),this[_0xa6a6('0x6')]['id'],this[_0xa6a6('0x14')]);if(_[_0xa6a6('0x1b')](this[_0xa6a6('0x12')]['agents'][this[_0xa6a6('0x14')]])){logger[_0xa6a6('0x16')](_0xa6a6('0x1c'),this[_0xa6a6('0x6')]['id'],this['agentId']);_0x269083[_0xa6a6('0x17')]();setTimeout(this[_0xa6a6('0x9')]['bind'](this),0x3e8);}else{if(util['isAgentAvailable'](this[_0xa6a6('0x6')]['id'],this[_0xa6a6('0x12')][_0xa6a6('0x13')][this['agentId']],this['squeue']['channel'],!![])){this[_0xa6a6('0x12')]['agents'][this[_0xa6a6('0x14')]][_0xa6a6('0x1d')]=!![];this[_0xa6a6('0x12')][_0xa6a6('0x13')][this['agentId']][_0xa6a6('0x1e')]=this['queue'][_0xa6a6('0x1f')];util['saveWaitingNotification'](this[_0xa6a6('0x12')],this[_0xa6a6('0x4')],this[_0xa6a6('0x12')][_0xa6a6('0x13')][this[_0xa6a6('0x14')]],this['squeue'][_0xa6a6('0x15')]);util[_0xa6a6('0x20')](this[_0xa6a6('0x5')],this[_0xa6a6('0x6')]['id'],this['realtime'][_0xa6a6('0x13')][this['agentId']],this[_0xa6a6('0x7')],this['routing']);util['writeLog'](this[_0xa6a6('0x6')]['id'],this[_0xa6a6('0x12')][_0xa6a6('0x13')][this['agentId']],_0xa6a6('0x21'));this[_0xa6a6('0x8')][this[_0xa6a6('0x14')]]=setInterval(this['handleCheckReject'][_0xa6a6('0xa')](this,_0x269083),0x3e8);}else{logger[_0xa6a6('0x16')](_0xa6a6('0x22'),this[_0xa6a6('0x6')]['id'],this[_0xa6a6('0x14')]);_0x269083[_0xa6a6('0x17')]();setTimeout(this[_0xa6a6('0x9')]['bind'](this),0x3e8);}}};RRMemory[_0xa6a6('0xf')][_0xa6a6('0xb')]=function(_0x279e68){logger['debug']('[%s][QUEUE]\x20timeout\x20with\x20%s',this[_0xa6a6('0x6')]['id'],this['agentId']);if(_[_0xa6a6('0x1b')](this[_0xa6a6('0x12')][_0xa6a6('0x13')][this['agentId']])){logger[_0xa6a6('0x16')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0xa6a6('0x6')]['id'],this['agentId']);}else{clearInterval(this[_0xa6a6('0x8')][this['agentId']]);util['hideNotification'](this[_0xa6a6('0x5')],this[_0xa6a6('0x6')]['id'],this['realtime'][_0xa6a6('0x13')][this[_0xa6a6('0x14')]],this[_0xa6a6('0x7')],this[_0xa6a6('0x4')]);util[_0xa6a6('0x23')](this[_0xa6a6('0x6')]['id'],this[_0xa6a6('0x12')][_0xa6a6('0x13')][this['agentId']],'TIMEOUT');this[_0xa6a6('0x12')][_0xa6a6('0x13')][this[_0xa6a6('0x14')]][_0xa6a6('0x1d')]=![];this[_0xa6a6('0x12')][_0xa6a6('0x13')][this[_0xa6a6('0x14')]][_0xa6a6('0x1e')]=undefined;util[_0xa6a6('0x24')](this[_0xa6a6('0x12')],this[_0xa6a6('0x4')],this['realtime'][_0xa6a6('0x13')][this[_0xa6a6('0x14')]],this[_0xa6a6('0x6')][_0xa6a6('0x15')]);}if(!_0x279e68){setTimeout(this['push'][_0xa6a6('0xa')](this),0x3e8);}};function rrmemory(_0x282b9c,_0x13ee9b,_0xbe5cf2,_0x531aa5){return new RRMemory(_0x282b9c,_0x13ee9b,_0xbe5cf2,_0x531aa5);}module[_0xa6a6('0x25')]=rrmemory;