Built motion from commit 43538d75.|2.5.35
[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 _0x6bc3=['channel','info','[%s][QUEUE]\x20available\x20again\x20%s','agentId','mapAgentsId','[%s][QUEUE]\x20try\x20with\x20%s','isNil','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','done','busy','name','showNotification','RINGING','handleCheckReject','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','[%s][QUEUE]\x20timeout\x20with\x20%s','writeLog','TIMEOUT','busyQueue','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','intervals','push','handleTimeout','module','timeout','bind','drained','handleDrained','handleRun','prototype','isAgentAvailable','agents'];(function(_0x579f0c,_0x36d640){var _0x2d8955=function(_0x5e361){while(--_0x5e361){_0x579f0c['push'](_0x579f0c['shift']());}};_0x2d8955(++_0x36d640);}(_0x6bc3,0x10a));var _0x36bc=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0x6bc3[_0x14add3];return _0x4a174f;};'use strict';var rr=require('rr');var _=require(_0x36bc('0x0'));var uuid=require(_0x36bc('0x1'));var util=require(_0x36bc('0x2'));var logger=require(_0x36bc('0x3'))(_0x36bc('0x4'));var RRMemory=function(_0x7aba54,_0xa04544,_0xf2393,_0x34149f){this[_0x36bc('0x5')]=uuid['v4']();this[_0x36bc('0x6')]=_0x7aba54;this[_0x36bc('0x7')]=_0xa04544;this[_0x36bc('0x8')]=_0xf2393;this[_0x36bc('0x4')]=_0x34149f;this[_0x36bc('0x9')]={};this[_0x36bc('0x6')][_0x36bc('0xa')](this['handleRun']['bind'](this),this[_0x36bc('0xb')]['bind'](this),this[_0x36bc('0xc')]);this[_0x36bc('0x6')]['on'](_0x36bc('0xd'),this[_0x36bc('0xb')][_0x36bc('0xe')](this));this[_0x36bc('0x6')]['on'](_0x36bc('0xf'),this[_0x36bc('0x10')][_0x36bc('0xe')](this));};RRMemory['prototype'][_0x36bc('0xa')]=function(){this['squeue'][_0x36bc('0xa')](this[_0x36bc('0x11')][_0x36bc('0xe')](this),this[_0x36bc('0xb')][_0x36bc('0xe')](this));};RRMemory[_0x36bc('0x12')][_0x36bc('0x10')]=function(_0x3c0c7e){this[_0x36bc('0xb')](!![]);};RRMemory[_0x36bc('0x12')]['handleCheckReject']=function(_0x16ec6c){if(util[_0x36bc('0x13')](this[_0x36bc('0x6')]['id'],this[_0x36bc('0x8')][_0x36bc('0x14')][this['agentId']],this[_0x36bc('0x6')][_0x36bc('0x15')],!![])){logger[_0x36bc('0x16')](_0x36bc('0x17'),this['squeue']['id'],this[_0x36bc('0x18')]);clearInterval(this[_0x36bc('0x9')][this[_0x36bc('0x18')]]);_0x16ec6c['done']();setTimeout(this[_0x36bc('0xa')][_0x36bc('0xe')](this),0x3e8);}};RRMemory[_0x36bc('0x12')][_0x36bc('0x11')]=function(_0xd1a3ff){this[_0x36bc('0x18')]=rr(this['queue'][_0x36bc('0x19')]);logger[_0x36bc('0x16')](_0x36bc('0x1a'),this[_0x36bc('0x6')]['id'],this[_0x36bc('0x18')]);if(_[_0x36bc('0x1b')](this['realtime'][_0x36bc('0x14')][this[_0x36bc('0x18')]])){logger['info'](_0x36bc('0x1c'),this['squeue']['id'],this[_0x36bc('0x18')]);_0xd1a3ff[_0x36bc('0x1d')]();setTimeout(this[_0x36bc('0xa')][_0x36bc('0xe')](this),0x3e8);}else{if(util['isAgentAvailable'](this['squeue']['id'],this[_0x36bc('0x8')][_0x36bc('0x14')][this[_0x36bc('0x18')]],this['squeue']['channel'],!![])){this['realtime'][_0x36bc('0x14')][this['agentId']][_0x36bc('0x1e')]=!![];this[_0x36bc('0x8')][_0x36bc('0x14')][this['agentId']]['busyQueue']=this[_0x36bc('0x7')][_0x36bc('0x1f')];util[_0x36bc('0x20')](this[_0x36bc('0x5')],this[_0x36bc('0x6')]['id'],this[_0x36bc('0x8')][_0x36bc('0x14')][this[_0x36bc('0x18')]],this[_0x36bc('0x7')],this[_0x36bc('0x4')]);util['writeLog'](this['squeue']['id'],this['realtime'][_0x36bc('0x14')][this[_0x36bc('0x18')]],_0x36bc('0x21'));this[_0x36bc('0x9')][this[_0x36bc('0x18')]]=setInterval(this[_0x36bc('0x22')]['bind'](this,_0xd1a3ff),0x3e8);}else{logger[_0x36bc('0x16')](_0x36bc('0x23'),this[_0x36bc('0x6')]['id'],this[_0x36bc('0x18')]);_0xd1a3ff[_0x36bc('0x1d')]();setTimeout(this[_0x36bc('0xa')][_0x36bc('0xe')](this),0x3e8);}}};RRMemory[_0x36bc('0x12')][_0x36bc('0xb')]=function(_0x5bb2db){logger[_0x36bc('0x16')](_0x36bc('0x24'),this[_0x36bc('0x6')]['id'],this[_0x36bc('0x18')]);if(_['isNil'](this[_0x36bc('0x8')][_0x36bc('0x14')][this[_0x36bc('0x18')]])){logger[_0x36bc('0x16')](_0x36bc('0x1c'),this[_0x36bc('0x6')]['id'],this['agentId']);}else{clearInterval(this[_0x36bc('0x9')][this[_0x36bc('0x18')]]);util['hideNotification'](this['notificationId'],this[_0x36bc('0x6')]['id'],this['realtime'][_0x36bc('0x14')][this[_0x36bc('0x18')]],this[_0x36bc('0x7')],this[_0x36bc('0x4')]);util[_0x36bc('0x25')](this['squeue']['id'],this[_0x36bc('0x8')][_0x36bc('0x14')][this[_0x36bc('0x18')]],_0x36bc('0x26'));this[_0x36bc('0x8')][_0x36bc('0x14')][this[_0x36bc('0x18')]]['busy']=![];this[_0x36bc('0x8')][_0x36bc('0x14')][this[_0x36bc('0x18')]][_0x36bc('0x27')]=undefined;}if(!_0x5bb2db){setTimeout(this['push'][_0x36bc('0xe')](this),0x3e8);}};function rrmemory(_0x1d0fb6,_0x3efcac,_0x1c491c,_0x264921){return new RRMemory(_0x1d0fb6,_0x3efcac,_0x1c491c,_0x264921);}module[_0x36bc('0x28')]=rrmemory;