Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / services / routing / server / applications / strategy / rrmemory.js
index 66be199..323ffd5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe1d1=['module','timeout','drained','handleDrained','prototype','handleCheckReject','isAgentAvailable','realtime','agentId','channel','info','[%s][QUEUE]\x20available\x20again\x20%s','done','mapAgentsId','[%s][QUEUE]\x20try\x20with\x20%s','isNil','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','agents','busy','busyQueue','name','showNotification','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','[%s][QUEUE]\x20timeout\x20with\x20%s','hideNotification','queue','TIMEOUT','exports','uuid','./util','../../../../../config/logger','notificationId','squeue','routing','intervals','push','handleRun','bind','handleTimeout'];(function(_0x3adf63,_0x56b2e6){var _0x5207a6=function(_0x2e5ef9){while(--_0x2e5ef9){_0x3adf63['push'](_0x3adf63['shift']());}};_0x5207a6(++_0x56b2e6);}(_0xe1d1,0xdf));var _0x1e1d=function(_0x11005e,_0x20c3d2){_0x11005e=_0x11005e-0x0;var _0x29338f=_0xe1d1[_0x11005e];return _0x29338f;};'use strict';var rr=require('rr');var _=require('lodash');var uuid=require(_0x1e1d('0x0'));var util=require(_0x1e1d('0x1'));var logger=require(_0x1e1d('0x2'))('routing');var RRMemory=function(_0x3d947c,_0x4b55db,_0x429e0b,_0x4ca69f){this[_0x1e1d('0x3')]=uuid['v4']();this[_0x1e1d('0x4')]=_0x3d947c;this['queue']=_0x4b55db;this['realtime']=_0x429e0b;this[_0x1e1d('0x5')]=_0x4ca69f;this[_0x1e1d('0x6')]={};this[_0x1e1d('0x4')][_0x1e1d('0x7')](this[_0x1e1d('0x8')][_0x1e1d('0x9')](this),this[_0x1e1d('0xa')]['bind'](this),this[_0x1e1d('0xb')]);this[_0x1e1d('0x4')]['on'](_0x1e1d('0xc'),this[_0x1e1d('0xa')][_0x1e1d('0x9')](this));this[_0x1e1d('0x4')]['on'](_0x1e1d('0xd'),this[_0x1e1d('0xe')]['bind'](this));};RRMemory[_0x1e1d('0xf')][_0x1e1d('0x7')]=function(){this[_0x1e1d('0x4')]['push'](this[_0x1e1d('0x8')]['bind'](this),this[_0x1e1d('0xa')]['bind'](this));};RRMemory[_0x1e1d('0xf')][_0x1e1d('0xe')]=function(_0x5ba6a8){this[_0x1e1d('0xa')](!![]);};RRMemory[_0x1e1d('0xf')][_0x1e1d('0x10')]=function(_0x329027){if(util[_0x1e1d('0x11')](this[_0x1e1d('0x4')]['id'],this[_0x1e1d('0x12')]['agents'][this[_0x1e1d('0x13')]],this[_0x1e1d('0x4')][_0x1e1d('0x14')],!![])){logger[_0x1e1d('0x15')](_0x1e1d('0x16'),this[_0x1e1d('0x4')]['id'],this[_0x1e1d('0x13')]);clearInterval(this[_0x1e1d('0x6')][this['agentId']]);_0x329027[_0x1e1d('0x17')]();setTimeout(this[_0x1e1d('0x7')]['bind'](this),0x3e8);}};RRMemory[_0x1e1d('0xf')][_0x1e1d('0x8')]=function(_0x163d5d){this['agentId']=rr(this['queue'][_0x1e1d('0x18')]);logger[_0x1e1d('0x15')](_0x1e1d('0x19'),this[_0x1e1d('0x4')]['id'],this[_0x1e1d('0x13')]);if(_[_0x1e1d('0x1a')](this[_0x1e1d('0x12')]['agents'][this[_0x1e1d('0x13')]])){logger[_0x1e1d('0x15')](_0x1e1d('0x1b'),this[_0x1e1d('0x4')]['id'],this['agentId']);_0x163d5d['done']();setTimeout(this[_0x1e1d('0x7')]['bind'](this),0x3e8);}else{if(util[_0x1e1d('0x11')](this[_0x1e1d('0x4')]['id'],this[_0x1e1d('0x12')][_0x1e1d('0x1c')][this[_0x1e1d('0x13')]],this[_0x1e1d('0x4')][_0x1e1d('0x14')],!![])){this[_0x1e1d('0x12')][_0x1e1d('0x1c')][this['agentId']][_0x1e1d('0x1d')]=!![];this[_0x1e1d('0x12')][_0x1e1d('0x1c')][this['agentId']][_0x1e1d('0x1e')]=this['queue'][_0x1e1d('0x1f')];util[_0x1e1d('0x20')](this['notificationId'],this['squeue']['id'],this[_0x1e1d('0x12')][_0x1e1d('0x1c')][this[_0x1e1d('0x13')]],this['queue'],this[_0x1e1d('0x5')]);util['writeLog'](this[_0x1e1d('0x4')]['id'],this[_0x1e1d('0x12')][_0x1e1d('0x1c')][this[_0x1e1d('0x13')]],'RINGING');this[_0x1e1d('0x6')][this[_0x1e1d('0x13')]]=setInterval(this['handleCheckReject']['bind'](this,_0x163d5d),0x3e8);}else{logger[_0x1e1d('0x15')](_0x1e1d('0x21'),this['squeue']['id'],this[_0x1e1d('0x13')]);_0x163d5d[_0x1e1d('0x17')]();setTimeout(this[_0x1e1d('0x7')][_0x1e1d('0x9')](this),0x3e8);}}};RRMemory[_0x1e1d('0xf')][_0x1e1d('0xa')]=function(_0xa2d1c7){logger[_0x1e1d('0x15')](_0x1e1d('0x22'),this[_0x1e1d('0x4')]['id'],this[_0x1e1d('0x13')]);if(_['isNil'](this[_0x1e1d('0x12')][_0x1e1d('0x1c')][this['agentId']])){logger['info']('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this['squeue']['id'],this['agentId']);}else{clearInterval(this['intervals'][this[_0x1e1d('0x13')]]);util[_0x1e1d('0x23')](this[_0x1e1d('0x3')],this[_0x1e1d('0x4')]['id'],this[_0x1e1d('0x12')][_0x1e1d('0x1c')][this['agentId']],this[_0x1e1d('0x24')],this[_0x1e1d('0x5')]);util['writeLog'](this['squeue']['id'],this[_0x1e1d('0x12')][_0x1e1d('0x1c')][this[_0x1e1d('0x13')]],_0x1e1d('0x25'));this[_0x1e1d('0x12')]['agents'][this['agentId']]['busy']=![];this['realtime']['agents'][this[_0x1e1d('0x13')]]['busyQueue']=undefined;}if(!_0xa2d1c7){setTimeout(this[_0x1e1d('0x7')][_0x1e1d('0x9')](this),0x3e8);}};function rrmemory(_0x2d122c,_0x2731f7,_0x496a5b,_0x538447){return new RRMemory(_0x2d122c,_0x2731f7,_0x496a5b,_0x538447);}module[_0x1e1d('0x26')]=rrmemory;
\ No newline at end of file
+var _0x91b5=['[%s][QUEUE]\x20try\x20with\x20%s','isNil','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','done','channel','busy','name','showNotification','writeLog','RINGING','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','hideNotification','TIMEOUT','./util','../../../../../config/logger','notificationId','squeue','queue','realtime','routing','intervals','push','handleRun','bind','handleTimeout','module','handleDrained','prototype','handleCheckReject','isAgentAvailable','agents','agentId','info','[%s][QUEUE]\x20available\x20again\x20%s'];(function(_0x111d44,_0x169f7e){var _0x53e96b=function(_0x2af72b){while(--_0x2af72b){_0x111d44['push'](_0x111d44['shift']());}};_0x53e96b(++_0x169f7e);}(_0x91b5,0xb7));var _0x591b=function(_0x3aecc1,_0x527393){_0x3aecc1=_0x3aecc1-0x0;var _0x3d032d=_0x91b5[_0x3aecc1];return _0x3d032d;};'use strict';var rr=require('rr');var _=require('lodash');var uuid=require('uuid');var util=require(_0x591b('0x0'));var logger=require(_0x591b('0x1'))('routing');var RRMemory=function(_0x3de47b,_0x5964c0,_0xcd392e,_0x924f30){this[_0x591b('0x2')]=uuid['v4']();this[_0x591b('0x3')]=_0x3de47b;this[_0x591b('0x4')]=_0x5964c0;this[_0x591b('0x5')]=_0xcd392e;this[_0x591b('0x6')]=_0x924f30;this[_0x591b('0x7')]={};this[_0x591b('0x3')][_0x591b('0x8')](this[_0x591b('0x9')][_0x591b('0xa')](this),this[_0x591b('0xb')]['bind'](this),this[_0x591b('0xc')]);this[_0x591b('0x3')]['on']('timeout',this[_0x591b('0xb')][_0x591b('0xa')](this));this[_0x591b('0x3')]['on']('drained',this[_0x591b('0xd')]['bind'](this));};RRMemory[_0x591b('0xe')][_0x591b('0x8')]=function(){this[_0x591b('0x3')][_0x591b('0x8')](this[_0x591b('0x9')][_0x591b('0xa')](this),this['handleTimeout'][_0x591b('0xa')](this));};RRMemory[_0x591b('0xe')][_0x591b('0xd')]=function(_0x3967b0){this[_0x591b('0xb')](!![]);};RRMemory[_0x591b('0xe')][_0x591b('0xf')]=function(_0x1854c2){if(util[_0x591b('0x10')](this[_0x591b('0x3')]['id'],this[_0x591b('0x5')][_0x591b('0x11')][this[_0x591b('0x12')]],this[_0x591b('0x3')]['channel'],!![])){logger[_0x591b('0x13')](_0x591b('0x14'),this[_0x591b('0x3')]['id'],this[_0x591b('0x12')]);clearInterval(this['intervals'][this[_0x591b('0x12')]]);_0x1854c2['done']();setTimeout(this['push'][_0x591b('0xa')](this),0x3e8);}};RRMemory[_0x591b('0xe')][_0x591b('0x9')]=function(_0x33671f){this['agentId']=rr(this['queue']['mapAgentsId']);logger[_0x591b('0x13')](_0x591b('0x15'),this['squeue']['id'],this['agentId']);if(_[_0x591b('0x16')](this[_0x591b('0x5')]['agents'][this[_0x591b('0x12')]])){logger['info'](_0x591b('0x17'),this[_0x591b('0x3')]['id'],this['agentId']);_0x33671f[_0x591b('0x18')]();setTimeout(this[_0x591b('0x8')][_0x591b('0xa')](this),0x3e8);}else{if(util['isAgentAvailable'](this['squeue']['id'],this[_0x591b('0x5')][_0x591b('0x11')][this['agentId']],this[_0x591b('0x3')][_0x591b('0x19')],!![])){this[_0x591b('0x5')]['agents'][this[_0x591b('0x12')]][_0x591b('0x1a')]=!![];this[_0x591b('0x5')][_0x591b('0x11')][this['agentId']]['busyQueue']=this[_0x591b('0x4')][_0x591b('0x1b')];util[_0x591b('0x1c')](this[_0x591b('0x2')],this[_0x591b('0x3')]['id'],this['realtime'][_0x591b('0x11')][this['agentId']],this[_0x591b('0x4')],this[_0x591b('0x6')]);util[_0x591b('0x1d')](this[_0x591b('0x3')]['id'],this[_0x591b('0x5')][_0x591b('0x11')][this[_0x591b('0x12')]],_0x591b('0x1e'));this[_0x591b('0x7')][this['agentId']]=setInterval(this[_0x591b('0xf')][_0x591b('0xa')](this,_0x33671f),0x3e8);}else{logger['info'](_0x591b('0x1f'),this['squeue']['id'],this['agentId']);_0x33671f[_0x591b('0x18')]();setTimeout(this[_0x591b('0x8')][_0x591b('0xa')](this),0x3e8);}}};RRMemory[_0x591b('0xe')]['handleTimeout']=function(_0x19803e){logger[_0x591b('0x13')]('[%s][QUEUE]\x20timeout\x20with\x20%s',this[_0x591b('0x3')]['id'],this[_0x591b('0x12')]);if(_['isNil'](this[_0x591b('0x5')][_0x591b('0x11')][this['agentId']])){logger['info']('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x591b('0x3')]['id'],this[_0x591b('0x12')]);}else{clearInterval(this[_0x591b('0x7')][this[_0x591b('0x12')]]);util[_0x591b('0x20')](this[_0x591b('0x2')],this[_0x591b('0x3')]['id'],this[_0x591b('0x5')][_0x591b('0x11')][this[_0x591b('0x12')]],this['queue'],this[_0x591b('0x6')]);util[_0x591b('0x1d')](this[_0x591b('0x3')]['id'],this[_0x591b('0x5')][_0x591b('0x11')][this['agentId']],_0x591b('0x21'));this[_0x591b('0x5')][_0x591b('0x11')][this[_0x591b('0x12')]][_0x591b('0x1a')]=![];this[_0x591b('0x5')][_0x591b('0x11')][this[_0x591b('0x12')]]['busyQueue']=undefined;}if(!_0x19803e){setTimeout(this[_0x591b('0x8')][_0x591b('0xa')](this),0x3e8);}};function rrmemory(_0x336c4a,_0xbc73e0,_0x55780a,_0x403cab){return new RRMemory(_0x336c4a,_0xbc73e0,_0x55780a,_0x403cab);}module['exports']=rrmemory;
\ No newline at end of file