46decfd817dbe8cf8641f44b7725a6f987535873
[motion-next.git] / server / services / routing / server / applications / strategy / rrmemory.js
1 const a1214_0x3474=['hideNotification','[%s][QUEUE]\x20try\x20with\x20%s','writeLog','drained','intervals','agents','busyQueue','channel','handleTimeout','handleCheckReject','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','busy','timeout','bind','name','isAgentAvailable','queue','push','uuid','done','notificationId','handleDrained','isNil','exports','agentId','[%s][QUEUE]\x20timeout\x20with\x20%s','TIMEOUT','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','realtime','../../../../../config/logger','squeue','handleRun','info','module','RINGING','lodash','prototype','routing'];(function(_0x2ab32c,_0x347414){const _0x25cafa=function(_0x6906be){while(--_0x6906be){_0x2ab32c['push'](_0x2ab32c['shift']());}};_0x25cafa(++_0x347414);}(a1214_0x3474,0xa3));const a1214_0x25ca=function(_0x2ab32c,_0x347414){_0x2ab32c=_0x2ab32c-0x0;let _0x25cafa=a1214_0x3474[_0x2ab32c];return _0x25cafa;};const _0x33a8ef=a1214_0x25ca;'use strict';const rr=require('rr'),_=require(_0x33a8ef('0x18')),uuid=require(_0x33a8ef('0x7')),util=require('./util'),logger=require(_0x33a8ef('0x12'))(_0x33a8ef('0x1a')),RRMemory=function(_0x6906be,_0x2cb83e,_0x199e85,_0x53cac5){const _0x4da5b1=_0x33a8ef;this[_0x4da5b1('0x9')]=uuid['v4'](),this[_0x4da5b1('0x13')]=_0x6906be,this[_0x4da5b1('0x5')]=_0x2cb83e,this['realtime']=_0x199e85,this['routing']=_0x53cac5,this['intervals']={},this[_0x4da5b1('0x13')][_0x4da5b1('0x6')](this['handleRun'][_0x4da5b1('0x2')](this),this[_0x4da5b1('0x23')][_0x4da5b1('0x2')](this),this[_0x4da5b1('0x16')]),this['squeue']['on'](_0x4da5b1('0x1'),this[_0x4da5b1('0x23')][_0x4da5b1('0x2')](this)),this[_0x4da5b1('0x13')]['on'](_0x4da5b1('0x1e'),this[_0x4da5b1('0xa')]['bind'](this));};RRMemory[_0x33a8ef('0x19')][_0x33a8ef('0x6')]=function(){const _0x45fa50=_0x33a8ef;this[_0x45fa50('0x13')][_0x45fa50('0x6')](this[_0x45fa50('0x14')][_0x45fa50('0x2')](this),this[_0x45fa50('0x23')][_0x45fa50('0x2')](this));},RRMemory['prototype'][_0x33a8ef('0xa')]=function(){const _0x3f0833=_0x33a8ef;this[_0x3f0833('0x23')](!![]);},RRMemory[_0x33a8ef('0x19')][_0x33a8ef('0x24')]=function(_0x244011){const _0x2ed9a1=_0x33a8ef;util[_0x2ed9a1('0x4')](this[_0x2ed9a1('0x13')]['id'],this[_0x2ed9a1('0x11')][_0x2ed9a1('0x20')][this['agentId']],this[_0x2ed9a1('0x13')][_0x2ed9a1('0x22')],!![])&&(logger['info']('[%s][QUEUE]\x20available\x20again\x20%s',this[_0x2ed9a1('0x13')]['id'],this[_0x2ed9a1('0xd')]),clearInterval(this['intervals'][this[_0x2ed9a1('0xd')]]),_0x244011['done'](),setTimeout(this[_0x2ed9a1('0x6')]['bind'](this),0x3e8));},RRMemory['prototype'][_0x33a8ef('0x14')]=function(_0x1aea85){const _0x546a5b=_0x33a8ef;this[_0x546a5b('0xd')]=rr(this[_0x546a5b('0x5')]['mapAgentsId']),logger[_0x546a5b('0x15')](_0x546a5b('0x1c'),this[_0x546a5b('0x13')]['id'],this[_0x546a5b('0xd')]),_['isNil'](this[_0x546a5b('0x11')]['agents'][this['agentId']])?(logger[_0x546a5b('0x15')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x546a5b('0x13')]['id'],this[_0x546a5b('0xd')]),_0x1aea85[_0x546a5b('0x8')](),setTimeout(this['push'][_0x546a5b('0x2')](this),0x3e8)):util[_0x546a5b('0x4')](this['squeue']['id'],this[_0x546a5b('0x11')][_0x546a5b('0x20')][this[_0x546a5b('0xd')]],this[_0x546a5b('0x13')][_0x546a5b('0x22')],!![])?(this[_0x546a5b('0x11')]['agents'][this[_0x546a5b('0xd')]][_0x546a5b('0x0')]=!![],this[_0x546a5b('0x11')][_0x546a5b('0x20')][this[_0x546a5b('0xd')]][_0x546a5b('0x21')]=this[_0x546a5b('0x5')][_0x546a5b('0x3')],util['showNotification'](this['notificationId'],this[_0x546a5b('0x13')]['id'],this['realtime'][_0x546a5b('0x20')][this['agentId']],this['queue'],this[_0x546a5b('0x1a')]),util[_0x546a5b('0x1d')](this[_0x546a5b('0x13')]['id'],this[_0x546a5b('0x11')][_0x546a5b('0x20')][this[_0x546a5b('0xd')]],_0x546a5b('0x17')),this['intervals'][this[_0x546a5b('0xd')]]=setInterval(this[_0x546a5b('0x24')][_0x546a5b('0x2')](this,_0x1aea85),0x3e8)):(logger[_0x546a5b('0x15')](_0x546a5b('0x10'),this[_0x546a5b('0x13')]['id'],this[_0x546a5b('0xd')]),_0x1aea85['done'](),setTimeout(this['push'][_0x546a5b('0x2')](this),0x3e8));},RRMemory['prototype']['handleTimeout']=function(_0x265327){const _0x4eec29=_0x33a8ef;logger[_0x4eec29('0x15')](_0x4eec29('0xe'),this[_0x4eec29('0x13')]['id'],this[_0x4eec29('0xd')]),_[_0x4eec29('0xb')](this[_0x4eec29('0x11')][_0x4eec29('0x20')][this[_0x4eec29('0xd')]])?logger[_0x4eec29('0x15')](_0x4eec29('0x25'),this[_0x4eec29('0x13')]['id'],this[_0x4eec29('0xd')]):(clearInterval(this[_0x4eec29('0x1f')][this['agentId']]),util[_0x4eec29('0x1b')](this[_0x4eec29('0x9')],this[_0x4eec29('0x13')]['id'],this[_0x4eec29('0x11')]['agents'][this[_0x4eec29('0xd')]],this[_0x4eec29('0x5')],this[_0x4eec29('0x1a')]),util[_0x4eec29('0x1d')](this['squeue']['id'],this[_0x4eec29('0x11')][_0x4eec29('0x20')][this[_0x4eec29('0xd')]],_0x4eec29('0xf')),this[_0x4eec29('0x11')][_0x4eec29('0x20')][this[_0x4eec29('0xd')]]['busy']=![],this['realtime'][_0x4eec29('0x20')][this[_0x4eec29('0xd')]][_0x4eec29('0x21')]=undefined),!_0x265327&&setTimeout(this[_0x4eec29('0x6')][_0x4eec29('0x2')](this),0x3e8);};function rrmemory(_0x5d9db4,_0xf33b9f,_0x452dd2,_0x2c3041){return new RRMemory(_0x5d9db4,_0xf33b9f,_0x452dd2,_0x2c3041);}module[_0x33a8ef('0xc')]=rrmemory;