Built motion from commit 994c64e1.|2.6.1
[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 _0x3226=['[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','busy','busyQueue','name','showNotification','writeLog','RINGING','intervals','[%s][QUEUE]\x20timeout\x20with\x20%s','isNil','TIMEOUT','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','queue','realtime','squeue','push','handleRun','bind','handleTimeout','module','timeout','drained','prototype','handleDrained','handleCheckReject','agentId','channel','info','done','[%s][QUEUE]\x20try\x20with\x20%s','agents'];(function(_0x10e05d,_0x5e0b67){var _0x4293e9=function(_0x5e27f7){while(--_0x5e27f7){_0x10e05d['push'](_0x10e05d['shift']());}};_0x4293e9(++_0x5e0b67);}(_0x3226,0x7b));var _0x6322=function(_0x5c1361,_0x2815c7){_0x5c1361=_0x5c1361-0x0;var _0x52f59d=_0x3226[_0x5c1361];return _0x52f59d;};'use strict';var rr=require('rr');var _=require(_0x6322('0x0'));var uuid=require(_0x6322('0x1'));var util=require(_0x6322('0x2'));var logger=require(_0x6322('0x3'))(_0x6322('0x4'));var RRMemory=function(_0x2a5cb8,_0x4bab82,_0x5ae8ab,_0x20bba9){this[_0x6322('0x5')]=uuid['v4']();this['squeue']=_0x2a5cb8;this[_0x6322('0x6')]=_0x4bab82;this[_0x6322('0x7')]=_0x5ae8ab;this[_0x6322('0x4')]=_0x20bba9;this['intervals']={};this[_0x6322('0x8')][_0x6322('0x9')](this[_0x6322('0xa')][_0x6322('0xb')](this),this[_0x6322('0xc')][_0x6322('0xb')](this),this[_0x6322('0xd')]);this[_0x6322('0x8')]['on'](_0x6322('0xe'),this[_0x6322('0xc')][_0x6322('0xb')](this));this[_0x6322('0x8')]['on'](_0x6322('0xf'),this['handleDrained'][_0x6322('0xb')](this));};RRMemory[_0x6322('0x10')][_0x6322('0x9')]=function(){this['squeue'][_0x6322('0x9')](this[_0x6322('0xa')][_0x6322('0xb')](this),this[_0x6322('0xc')][_0x6322('0xb')](this));};RRMemory[_0x6322('0x10')][_0x6322('0x11')]=function(_0x2afe58){this[_0x6322('0xc')](!![]);};RRMemory[_0x6322('0x10')][_0x6322('0x12')]=function(_0x11c1e8){if(util['isAgentAvailable'](this[_0x6322('0x8')]['id'],this['realtime']['agents'][this[_0x6322('0x13')]],this['squeue'][_0x6322('0x14')],!![])){logger[_0x6322('0x15')]('[%s][QUEUE]\x20available\x20again\x20%s',this['squeue']['id'],this[_0x6322('0x13')]);clearInterval(this['intervals'][this[_0x6322('0x13')]]);_0x11c1e8[_0x6322('0x16')]();setTimeout(this[_0x6322('0x9')][_0x6322('0xb')](this),0x3e8);}};RRMemory[_0x6322('0x10')][_0x6322('0xa')]=function(_0x151021){this[_0x6322('0x13')]=rr(this[_0x6322('0x6')]['mapAgentsId']);logger[_0x6322('0x15')](_0x6322('0x17'),this[_0x6322('0x8')]['id'],this[_0x6322('0x13')]);if(_['isNil'](this[_0x6322('0x7')][_0x6322('0x18')][this[_0x6322('0x13')]])){logger['info'](_0x6322('0x19'),this['squeue']['id'],this['agentId']);_0x151021[_0x6322('0x16')]();setTimeout(this[_0x6322('0x9')][_0x6322('0xb')](this),0x3e8);}else{if(util['isAgentAvailable'](this[_0x6322('0x8')]['id'],this['realtime'][_0x6322('0x18')][this[_0x6322('0x13')]],this[_0x6322('0x8')][_0x6322('0x14')],!![])){this[_0x6322('0x7')][_0x6322('0x18')][this[_0x6322('0x13')]][_0x6322('0x1a')]=!![];this['realtime']['agents'][this[_0x6322('0x13')]][_0x6322('0x1b')]=this['queue'][_0x6322('0x1c')];util[_0x6322('0x1d')](this[_0x6322('0x5')],this['squeue']['id'],this[_0x6322('0x7')]['agents'][this[_0x6322('0x13')]],this['queue'],this[_0x6322('0x4')]);util[_0x6322('0x1e')](this[_0x6322('0x8')]['id'],this['realtime'][_0x6322('0x18')][this[_0x6322('0x13')]],_0x6322('0x1f'));this[_0x6322('0x20')][this['agentId']]=setInterval(this[_0x6322('0x12')][_0x6322('0xb')](this,_0x151021),0x3e8);}else{logger[_0x6322('0x15')]('[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s',this[_0x6322('0x8')]['id'],this[_0x6322('0x13')]);_0x151021[_0x6322('0x16')]();setTimeout(this[_0x6322('0x9')][_0x6322('0xb')](this),0x3e8);}}};RRMemory[_0x6322('0x10')][_0x6322('0xc')]=function(_0x57c55e){logger[_0x6322('0x15')](_0x6322('0x21'),this[_0x6322('0x8')]['id'],this[_0x6322('0x13')]);if(_[_0x6322('0x22')](this['realtime'][_0x6322('0x18')][this['agentId']])){logger[_0x6322('0x15')](_0x6322('0x19'),this[_0x6322('0x8')]['id'],this['agentId']);}else{clearInterval(this[_0x6322('0x20')][this[_0x6322('0x13')]]);util['hideNotification'](this[_0x6322('0x5')],this[_0x6322('0x8')]['id'],this[_0x6322('0x7')]['agents'][this['agentId']],this['queue'],this[_0x6322('0x4')]);util[_0x6322('0x1e')](this[_0x6322('0x8')]['id'],this[_0x6322('0x7')][_0x6322('0x18')][this[_0x6322('0x13')]],_0x6322('0x23'));this[_0x6322('0x7')][_0x6322('0x18')][this[_0x6322('0x13')]]['busy']=![];this[_0x6322('0x7')][_0x6322('0x18')][this['agentId']][_0x6322('0x1b')]=undefined;}if(!_0x57c55e){setTimeout(this[_0x6322('0x9')][_0x6322('0xb')](this),0x3e8);}};function rrmemory(_0x29c3db,_0x10145c,_0x573e6f,_0x59324c){return new RRMemory(_0x29c3db,_0x10145c,_0x573e6f,_0x59324c);}module[_0x6322('0x24')]=rrmemory;