Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / services / routing / server / applications / strategy / agent.js
index 763288d..deddb5c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x015a=['isAgentAvailable','realtime','channel','busy','busyQueue','showNotification','writeLog',':FORCED','[%s][AGENT]\x20timeout\x20with\x20%s','exports','lodash','./util','../../../../../config/logger','routing','notificationId','agent','squeue','push','handleRun','bind','handleTimeout','handleDrained','prototype','info','[%s][AGENT]\x20try\x20with\x20%s','isNil','agents','[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s','forcedOwnership'];(function(_0x55821d,_0x27a22e){var _0x58ea8a=function(_0x5bdd3d){while(--_0x5bdd3d){_0x55821d['push'](_0x55821d['shift']());}};_0x58ea8a(++_0x27a22e);}(_0x015a,0xf2));var _0xa015=function(_0x44946b,_0xf874ec){_0x44946b=_0x44946b-0x0;var _0x249bc4=_0x015a[_0x44946b];return _0x249bc4;};'use strict';var _=require(_0xa015('0x0'));var uuid=require('uuid');var util=require(_0xa015('0x1'));var logger=require(_0xa015('0x2'))(_0xa015('0x3'));var Agent=function(_0x5fedb3,_0x289f94,_0x12e98a,_0x6b6aad){this[_0xa015('0x4')]=uuid['v4']();this['squeue']=_0x5fedb3;this[_0xa015('0x5')]=_0x289f94;this['realtime']=_0x12e98a;this[_0xa015('0x3')]=_0x6b6aad;this[_0xa015('0x6')][_0xa015('0x7')](this[_0xa015('0x8')][_0xa015('0x9')](this),this[_0xa015('0xa')][_0xa015('0x9')](this));this['squeue']['on']('timeout',this[_0xa015('0xa')]['bind'](this));this[_0xa015('0x6')]['on']('drained',this[_0xa015('0xb')][_0xa015('0x9')](this));};Agent['prototype'][_0xa015('0x7')]=function(){this[_0xa015('0x6')]['push'](this[_0xa015('0x8')][_0xa015('0x9')](this),this[_0xa015('0xa')][_0xa015('0x9')](this));};Agent[_0xa015('0xc')][_0xa015('0xb')]=function(){this[_0xa015('0xa')](!![]);};Agent[_0xa015('0xc')][_0xa015('0x8')]=function(_0x358b63){logger[_0xa015('0xd')](_0xa015('0xe'),this[_0xa015('0x6')]['id'],this[_0xa015('0x5')]['id']);if(_[_0xa015('0xf')](this['realtime'][_0xa015('0x10')][this[_0xa015('0x5')]['id']])){logger[_0xa015('0xd')](_0xa015('0x11'),this[_0xa015('0x6')]['id'],this['agent']['id']);setTimeout(this[_0xa015('0x7')][_0xa015('0x9')](this),0x3e8);}else{if(this['routing'][_0xa015('0x12')]||util[_0xa015('0x13')](this[_0xa015('0x6')]['id'],this[_0xa015('0x14')][_0xa015('0x10')][this[_0xa015('0x5')]['id']],this[_0xa015('0x6')][_0xa015('0x15')],![])){this[_0xa015('0x14')]['agents'][this[_0xa015('0x5')]['id']][_0xa015('0x16')]=!![];this[_0xa015('0x14')]['agents'][this[_0xa015('0x5')]['id']][_0xa015('0x17')]=undefined;util[_0xa015('0x18')](this[_0xa015('0x4')],this['squeue']['id'],this['realtime'][_0xa015('0x10')][this[_0xa015('0x5')]['id']],null,this['routing']);util[_0xa015('0x19')](this[_0xa015('0x6')]['id'],this['realtime'][_0xa015('0x10')][this[_0xa015('0x5')]['id']],'RINGING'+(this[_0xa015('0x3')][_0xa015('0x12')]?_0xa015('0x1a'):''));}else{logger[_0xa015('0xd')]('[%s][AGENT]\x20agent\x20%s\x20is\x20not\x20available',this[_0xa015('0x6')]['id'],this[_0xa015('0x5')]['id']);setTimeout(this['push'][_0xa015('0x9')](this),0x3e8);}}};Agent[_0xa015('0xc')]['handleTimeout']=function(_0x3f2a97){if(_['isNil'](this[_0xa015('0x14')][_0xa015('0x10')][this['agent']['id']])){return logger[_0xa015('0xd')](_0xa015('0x11'),this[_0xa015('0x6')]['id'],this[_0xa015('0x5')]['id']);}else{logger[_0xa015('0xd')](_0xa015('0x1b'),this[_0xa015('0x6')]['id'],this[_0xa015('0x5')]['id']);util['hideNotification'](this[_0xa015('0x4')],this[_0xa015('0x6')]['id'],this[_0xa015('0x14')][_0xa015('0x10')][this[_0xa015('0x5')]['id']],null,this['routing']);this['realtime']['agents'][this['agent']['id']][_0xa015('0x16')]=![];this['realtime'][_0xa015('0x10')][this[_0xa015('0x5')]['id']]['busyQueue']=undefined;util[_0xa015('0x19')](this[_0xa015('0x6')]['id'],this[_0xa015('0x14')][_0xa015('0x10')][this['agent']['id']],_0x3f2a97?'STOP':'TIMEOUT');}if(!_0x3f2a97){setTimeout(this['push'][_0xa015('0x9')](this),0x3e8);}};function agent(_0x17b355,_0x8bebc2,_0x1b6fe0,_0x214d09){return new Agent(_0x17b355,_0x8bebc2,_0x1b6fe0,_0x214d09);}module[_0xa015('0x1c')]=agent;
\ No newline at end of file
+var _0x3768=['timeout','drained','prototype','handleRun','handleDrained','info','agents','[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s','forcedOwnership','isAgentAvailable','channel','busyQueue','showNotification','writeLog',':FORCED','isNil','STOP','TIMEOUT','uuid','../../../../../config/logger','routing','notificationId','squeue','agent','realtime','push','bind','handleTimeout'];(function(_0x3dd6ea,_0x3df362){var _0x2f79bb=function(_0x596871){while(--_0x596871){_0x3dd6ea['push'](_0x3dd6ea['shift']());}};_0x2f79bb(++_0x3df362);}(_0x3768,0x10e));var _0x8376=function(_0x4c05da,_0x414720){_0x4c05da=_0x4c05da-0x0;var _0x1614db=_0x3768[_0x4c05da];return _0x1614db;};'use strict';var _=require('lodash');var uuid=require(_0x8376('0x0'));var util=require('./util');var logger=require(_0x8376('0x1'))(_0x8376('0x2'));var Agent=function(_0x43e25e,_0x2c85f9,_0x419f90,_0x1eddc0){this[_0x8376('0x3')]=uuid['v4']();this[_0x8376('0x4')]=_0x43e25e;this[_0x8376('0x5')]=_0x2c85f9;this[_0x8376('0x6')]=_0x419f90;this['routing']=_0x1eddc0;this[_0x8376('0x4')][_0x8376('0x7')](this['handleRun'][_0x8376('0x8')](this),this[_0x8376('0x9')][_0x8376('0x8')](this));this[_0x8376('0x4')]['on'](_0x8376('0xa'),this[_0x8376('0x9')]['bind'](this));this[_0x8376('0x4')]['on'](_0x8376('0xb'),this['handleDrained'][_0x8376('0x8')](this));};Agent[_0x8376('0xc')][_0x8376('0x7')]=function(){this['squeue']['push'](this[_0x8376('0xd')][_0x8376('0x8')](this),this[_0x8376('0x9')][_0x8376('0x8')](this));};Agent[_0x8376('0xc')][_0x8376('0xe')]=function(){this['handleTimeout'](!![]);};Agent['prototype']['handleRun']=function(_0x396753){logger[_0x8376('0xf')]('[%s][AGENT]\x20try\x20with\x20%s',this[_0x8376('0x4')]['id'],this[_0x8376('0x5')]['id']);if(_['isNil'](this[_0x8376('0x6')][_0x8376('0x10')][this[_0x8376('0x5')]['id']])){logger['info'](_0x8376('0x11'),this[_0x8376('0x4')]['id'],this[_0x8376('0x5')]['id']);setTimeout(this['push'][_0x8376('0x8')](this),0x3e8);}else{if(this[_0x8376('0x2')][_0x8376('0x12')]||util[_0x8376('0x13')](this['squeue']['id'],this[_0x8376('0x6')]['agents'][this[_0x8376('0x5')]['id']],this[_0x8376('0x4')][_0x8376('0x14')],![])){this[_0x8376('0x6')][_0x8376('0x10')][this[_0x8376('0x5')]['id']]['busy']=!![];this[_0x8376('0x6')][_0x8376('0x10')][this[_0x8376('0x5')]['id']][_0x8376('0x15')]=undefined;util[_0x8376('0x16')](this['notificationId'],this[_0x8376('0x4')]['id'],this[_0x8376('0x6')]['agents'][this[_0x8376('0x5')]['id']],null,this[_0x8376('0x2')]);util[_0x8376('0x17')](this[_0x8376('0x4')]['id'],this['realtime'][_0x8376('0x10')][this[_0x8376('0x5')]['id']],'RINGING'+(this['routing'][_0x8376('0x12')]?_0x8376('0x18'):''));}else{logger[_0x8376('0xf')]('[%s][AGENT]\x20agent\x20%s\x20is\x20not\x20available',this[_0x8376('0x4')]['id'],this[_0x8376('0x5')]['id']);setTimeout(this[_0x8376('0x7')][_0x8376('0x8')](this),0x3e8);}}};Agent[_0x8376('0xc')]['handleTimeout']=function(_0x3f0840){if(_[_0x8376('0x19')](this[_0x8376('0x6')][_0x8376('0x10')][this[_0x8376('0x5')]['id']])){return logger[_0x8376('0xf')]('[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x8376('0x4')]['id'],this['agent']['id']);}else{logger['info']('[%s][AGENT]\x20timeout\x20with\x20%s',this[_0x8376('0x4')]['id'],this[_0x8376('0x5')]['id']);util['hideNotification'](this['notificationId'],this[_0x8376('0x4')]['id'],this[_0x8376('0x6')][_0x8376('0x10')][this[_0x8376('0x5')]['id']],null,this[_0x8376('0x2')]);this['realtime'][_0x8376('0x10')][this[_0x8376('0x5')]['id']]['busy']=![];this[_0x8376('0x6')][_0x8376('0x10')][this['agent']['id']][_0x8376('0x15')]=undefined;util['writeLog'](this[_0x8376('0x4')]['id'],this[_0x8376('0x6')][_0x8376('0x10')][this['agent']['id']],_0x3f0840?_0x8376('0x1a'):_0x8376('0x1b'));}if(!_0x3f0840){setTimeout(this['push'][_0x8376('0x8')](this),0x3e8);}};function agent(_0x492c65,_0x4cc72c,_0x44dc09,_0x3df52c){return new Agent(_0x492c65,_0x4cc72c,_0x44dc09,_0x3df52c);}module['exports']=agent;
\ No newline at end of file