b486d06d9edc11174c0571e041c17cdd49e787f2
[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 _0x2ea0=['intervals','push','bind','handleTimeout','module','timeout','handleDrained','prototype','handleCheckReject','isAgentAvailable','agents','agentId','channel','debug','[%s][QUEUE]\x20available\x20again\x20%s','handleRun','mapAgentsId','isNil','done','busyQueue','name','saveWaitingNotification','showNotification','writeLog','RINGING','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','hideNotification','TIMEOUT','busy','removeWaitingNotification','exports','lodash','uuid','./util','routing','notificationId','squeue','queue','realtime'];(function(_0x2d7f0e,_0x3e6fbd){var _0x110b07=function(_0x557b00){while(--_0x557b00){_0x2d7f0e['push'](_0x2d7f0e['shift']());}};_0x110b07(++_0x3e6fbd);}(_0x2ea0,0x70));var _0x02ea=function(_0x3ead55,_0x22bc51){_0x3ead55=_0x3ead55-0x0;var _0x3ea16d=_0x2ea0[_0x3ead55];return _0x3ea16d;};'use strict';var rr=require('rr');var _=require(_0x02ea('0x0'));var uuid=require(_0x02ea('0x1'));var util=require(_0x02ea('0x2'));var logger=require('../../../../../config/logger')(_0x02ea('0x3'));var RRMemory=function(_0x47f839,_0x2c3505,_0x5ba0ae,_0x1b683e){this[_0x02ea('0x4')]=uuid['v4']();this[_0x02ea('0x5')]=_0x47f839;this[_0x02ea('0x6')]=_0x2c3505;this[_0x02ea('0x7')]=_0x5ba0ae;this[_0x02ea('0x3')]=_0x1b683e;this[_0x02ea('0x8')]={};this[_0x02ea('0x5')][_0x02ea('0x9')](this['handleRun'][_0x02ea('0xa')](this),this[_0x02ea('0xb')][_0x02ea('0xa')](this),this[_0x02ea('0xc')]);this['squeue']['on'](_0x02ea('0xd'),this[_0x02ea('0xb')][_0x02ea('0xa')](this));this[_0x02ea('0x5')]['on']('drained',this[_0x02ea('0xe')][_0x02ea('0xa')](this));};RRMemory[_0x02ea('0xf')][_0x02ea('0x9')]=function(){this[_0x02ea('0x5')][_0x02ea('0x9')](this['handleRun']['bind'](this),this[_0x02ea('0xb')][_0x02ea('0xa')](this));};RRMemory['prototype'][_0x02ea('0xe')]=function(){this[_0x02ea('0xb')](!![]);};RRMemory[_0x02ea('0xf')][_0x02ea('0x10')]=function(_0x2147aa){if(util[_0x02ea('0x11')](this['squeue']['id'],this['realtime'][_0x02ea('0x12')][this[_0x02ea('0x13')]],this[_0x02ea('0x5')][_0x02ea('0x14')],!![])){logger[_0x02ea('0x15')](_0x02ea('0x16'),this[_0x02ea('0x5')]['id'],this[_0x02ea('0x13')]);clearInterval(this[_0x02ea('0x8')][this[_0x02ea('0x13')]]);_0x2147aa['done']();setTimeout(this[_0x02ea('0x9')][_0x02ea('0xa')](this),0x3e8);}};RRMemory[_0x02ea('0xf')][_0x02ea('0x17')]=function(_0x21b5cb){this[_0x02ea('0x13')]=rr(this[_0x02ea('0x6')][_0x02ea('0x18')]);logger[_0x02ea('0x15')]('[%s][QUEUE]\x20try\x20with\x20%s',this[_0x02ea('0x5')]['id'],this[_0x02ea('0x13')]);if(_[_0x02ea('0x19')](this[_0x02ea('0x7')][_0x02ea('0x12')][this[_0x02ea('0x13')]])){logger[_0x02ea('0x15')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x02ea('0x5')]['id'],this[_0x02ea('0x13')]);_0x21b5cb[_0x02ea('0x1a')]();setTimeout(this['push'][_0x02ea('0xa')](this),0x3e8);}else{if(util[_0x02ea('0x11')](this[_0x02ea('0x5')]['id'],this['realtime'][_0x02ea('0x12')][this[_0x02ea('0x13')]],this['squeue'][_0x02ea('0x14')],!![])){this['realtime'][_0x02ea('0x12')][this[_0x02ea('0x13')]]['busy']=!![];this[_0x02ea('0x7')][_0x02ea('0x12')][this[_0x02ea('0x13')]][_0x02ea('0x1b')]=this['queue'][_0x02ea('0x1c')];util[_0x02ea('0x1d')](this[_0x02ea('0x7')],this[_0x02ea('0x3')],this[_0x02ea('0x7')][_0x02ea('0x12')][this['agentId']],this[_0x02ea('0x5')][_0x02ea('0x14')]);util[_0x02ea('0x1e')](this[_0x02ea('0x4')],this[_0x02ea('0x5')]['id'],this[_0x02ea('0x7')][_0x02ea('0x12')][this[_0x02ea('0x13')]],this[_0x02ea('0x6')],this['routing']);util[_0x02ea('0x1f')](this[_0x02ea('0x5')]['id'],this[_0x02ea('0x7')][_0x02ea('0x12')][this[_0x02ea('0x13')]],_0x02ea('0x20'));this[_0x02ea('0x8')][this[_0x02ea('0x13')]]=setInterval(this[_0x02ea('0x10')][_0x02ea('0xa')](this,_0x21b5cb),0x3e8);}else{logger[_0x02ea('0x15')](_0x02ea('0x21'),this[_0x02ea('0x5')]['id'],this['agentId']);_0x21b5cb[_0x02ea('0x1a')]();setTimeout(this[_0x02ea('0x9')][_0x02ea('0xa')](this),0x3e8);}}};RRMemory[_0x02ea('0xf')][_0x02ea('0xb')]=function(_0xfc05d9){logger[_0x02ea('0x15')]('[%s][QUEUE]\x20timeout\x20with\x20%s',this[_0x02ea('0x5')]['id'],this[_0x02ea('0x13')]);if(_[_0x02ea('0x19')](this[_0x02ea('0x7')][_0x02ea('0x12')][this[_0x02ea('0x13')]])){logger[_0x02ea('0x15')](_0x02ea('0x22'),this['squeue']['id'],this[_0x02ea('0x13')]);}else{clearInterval(this[_0x02ea('0x8')][this['agentId']]);util[_0x02ea('0x23')](this[_0x02ea('0x4')],this[_0x02ea('0x5')]['id'],this[_0x02ea('0x7')][_0x02ea('0x12')][this[_0x02ea('0x13')]],this[_0x02ea('0x6')],this[_0x02ea('0x3')]);util[_0x02ea('0x1f')](this['squeue']['id'],this[_0x02ea('0x7')]['agents'][this[_0x02ea('0x13')]],_0x02ea('0x24'));this[_0x02ea('0x7')][_0x02ea('0x12')][this[_0x02ea('0x13')]][_0x02ea('0x25')]=![];this[_0x02ea('0x7')]['agents'][this[_0x02ea('0x13')]]['busyQueue']=undefined;util[_0x02ea('0x26')](this[_0x02ea('0x7')],this['routing'],this[_0x02ea('0x7')][_0x02ea('0x12')][this['agentId']],this['squeue'][_0x02ea('0x14')]);}if(!_0xfc05d9){setTimeout(this[_0x02ea('0x9')][_0x02ea('0xa')](this),0x3e8);}};function rrmemory(_0x4caa10,_0x50e98a,_0x2d92fe,_0x473b8a){return new RRMemory(_0x4caa10,_0x50e98a,_0x2d92fe,_0x473b8a);}module[_0x02ea('0x27')]=rrmemory;