Built motion from commit cb845558.|2.6.34
[motion2.git] / server / services / routing / server / applications / strategy / agent.js
index 2536ff8..62dc608 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0a9a=['writeLog','STOP','exports','uuid','../../../../../config/logger','routing','notificationId','agent','realtime','squeue','handleRun','handleTimeout','bind','timeout','prototype','handleDrained','debug','[%s][AGENT]\x20try\x20with\x20%s','isNil','agents','[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s','push','forcedOwnership','isAgentAvailable','channel','busy','saveWaitingNotification',':FORCED','[%s][AGENT]\x20timeout\x20with\x20%s','hideNotification','busyQueue','removeWaitingNotification'];(function(_0x46b9bf,_0x3c9e5d){var _0xe4b4ac=function(_0x59da47){while(--_0x59da47){_0x46b9bf['push'](_0x46b9bf['shift']());}};_0xe4b4ac(++_0x3c9e5d);}(_0x0a9a,0x183));var _0xa0a9=function(_0x48ba23,_0x45401b){_0x48ba23=_0x48ba23-0x0;var _0x4d39ef=_0x0a9a[_0x48ba23];return _0x4d39ef;};'use strict';var _=require('lodash');var uuid=require(_0xa0a9('0x0'));var util=require('./util');var logger=require(_0xa0a9('0x1'))(_0xa0a9('0x2'));var Agent=function(_0x34801b,_0x49162f,_0x4ba993,_0x317a94){this[_0xa0a9('0x3')]=uuid['v4']();this['squeue']=_0x34801b;this[_0xa0a9('0x4')]=_0x49162f;this[_0xa0a9('0x5')]=_0x4ba993;this[_0xa0a9('0x2')]=_0x317a94;this[_0xa0a9('0x6')]['push'](this[_0xa0a9('0x7')]['bind'](this),this[_0xa0a9('0x8')][_0xa0a9('0x9')](this));this[_0xa0a9('0x6')]['on'](_0xa0a9('0xa'),this['handleTimeout'][_0xa0a9('0x9')](this));this[_0xa0a9('0x6')]['on']('drained',this['handleDrained'][_0xa0a9('0x9')](this));};Agent[_0xa0a9('0xb')]['push']=function(){this[_0xa0a9('0x6')]['push'](this[_0xa0a9('0x7')]['bind'](this),this[_0xa0a9('0x8')][_0xa0a9('0x9')](this));};Agent[_0xa0a9('0xb')][_0xa0a9('0xc')]=function(){this[_0xa0a9('0x8')](!![]);};Agent['prototype'][_0xa0a9('0x7')]=function(){logger[_0xa0a9('0xd')](_0xa0a9('0xe'),this[_0xa0a9('0x6')]['id'],this[_0xa0a9('0x4')]['id']);if(_[_0xa0a9('0xf')](this['realtime'][_0xa0a9('0x10')][this['agent']['id']])){logger['debug'](_0xa0a9('0x11'),this[_0xa0a9('0x6')]['id'],this[_0xa0a9('0x4')]['id']);setTimeout(this[_0xa0a9('0x12')]['bind'](this),0x3e8);}else{if(this[_0xa0a9('0x2')][_0xa0a9('0x13')]||util[_0xa0a9('0x14')](this[_0xa0a9('0x6')]['id'],this[_0xa0a9('0x5')][_0xa0a9('0x10')][this['agent']['id']],this[_0xa0a9('0x6')][_0xa0a9('0x15')],![])){this['realtime']['agents'][this[_0xa0a9('0x4')]['id']][_0xa0a9('0x16')]=!![];this[_0xa0a9('0x5')]['agents'][this[_0xa0a9('0x4')]['id']]['busyQueue']=undefined;util[_0xa0a9('0x17')](this['realtime'],this[_0xa0a9('0x2')],this[_0xa0a9('0x4')],this[_0xa0a9('0x6')][_0xa0a9('0x15')]);util['showNotification'](this[_0xa0a9('0x3')],this['squeue']['id'],this[_0xa0a9('0x5')][_0xa0a9('0x10')][this[_0xa0a9('0x4')]['id']],null,this[_0xa0a9('0x2')]);util['writeLog'](this[_0xa0a9('0x6')]['id'],this[_0xa0a9('0x5')][_0xa0a9('0x10')][this[_0xa0a9('0x4')]['id']],'RINGING'+(this[_0xa0a9('0x2')][_0xa0a9('0x13')]?_0xa0a9('0x18'):''));}else{logger['debug']('[%s][AGENT]\x20agent\x20%s\x20is\x20not\x20available',this[_0xa0a9('0x6')]['id'],this[_0xa0a9('0x4')]['id']);setTimeout(this[_0xa0a9('0x12')][_0xa0a9('0x9')](this),0x3e8);}}};Agent[_0xa0a9('0xb')][_0xa0a9('0x8')]=function(_0x2386c9){if(_[_0xa0a9('0xf')](this[_0xa0a9('0x5')][_0xa0a9('0x10')][this[_0xa0a9('0x4')]['id']])){return logger['debug'](_0xa0a9('0x11'),this[_0xa0a9('0x6')]['id'],this['agent']['id']);}else{logger[_0xa0a9('0xd')](_0xa0a9('0x19'),this['squeue']['id'],this['agent']['id']);util[_0xa0a9('0x1a')](this['notificationId'],this['squeue']['id'],this[_0xa0a9('0x5')][_0xa0a9('0x10')][this[_0xa0a9('0x4')]['id']],null,this[_0xa0a9('0x2')]);this[_0xa0a9('0x5')][_0xa0a9('0x10')][this[_0xa0a9('0x4')]['id']]['busy']=![];this[_0xa0a9('0x5')][_0xa0a9('0x10')][this['agent']['id']][_0xa0a9('0x1b')]=undefined;util[_0xa0a9('0x1c')](this[_0xa0a9('0x5')],this['routing'],this['agent'],this[_0xa0a9('0x6')][_0xa0a9('0x15')]);util[_0xa0a9('0x1d')](this[_0xa0a9('0x6')]['id'],this['realtime'][_0xa0a9('0x10')][this[_0xa0a9('0x4')]['id']],_0x2386c9?_0xa0a9('0x1e'):'TIMEOUT');}if(!_0x2386c9){setTimeout(this[_0xa0a9('0x12')][_0xa0a9('0x9')](this),0x3e8);}};function agent(_0x4e121e,_0x53dfd1,_0x3ae735,_0x2ed673){return new Agent(_0x4e121e,_0x53dfd1,_0x3ae735,_0x2ed673);}module[_0xa0a9('0x1f')]=agent;
\ No newline at end of file
+var _0x6c7b=['saveWaitingNotification','showNotification','notificationId','RINGING','isNil','hideNotification','removeWaitingNotification','writeLog','STOP','TIMEOUT','exports','lodash','routing','squeue','agent','realtime','handleRun','bind','handleTimeout','timeout','handleDrained','prototype','push','[%s][AGENT]\x20try\x20with\x20%s','debug','[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s','forcedOwnership','isAgentAvailable','agents','channel','busy','busyQueue'];(function(_0x1285b7,_0x4f16c5){var _0x3c3475=function(_0xda5052){while(--_0xda5052){_0x1285b7['push'](_0x1285b7['shift']());}};_0x3c3475(++_0x4f16c5);}(_0x6c7b,0x10b));var _0xb6c7=function(_0x56242d,_0x1dd061){_0x56242d=_0x56242d-0x0;var _0x5d7033=_0x6c7b[_0x56242d];return _0x5d7033;};'use strict';var _=require(_0xb6c7('0x0'));var uuid=require('uuid');var util=require('./util');var logger=require('../../../../../config/logger')(_0xb6c7('0x1'));var Agent=function(_0x5528b3,_0x2b678a,_0x438aa8,_0x35674b){this['notificationId']=uuid['v4']();this[_0xb6c7('0x2')]=_0x5528b3;this[_0xb6c7('0x3')]=_0x2b678a;this[_0xb6c7('0x4')]=_0x438aa8;this[_0xb6c7('0x1')]=_0x35674b;this[_0xb6c7('0x2')]['push'](this[_0xb6c7('0x5')][_0xb6c7('0x6')](this),this[_0xb6c7('0x7')][_0xb6c7('0x6')](this));this[_0xb6c7('0x2')]['on'](_0xb6c7('0x8'),this[_0xb6c7('0x7')][_0xb6c7('0x6')](this));this['squeue']['on']('drained',this[_0xb6c7('0x9')][_0xb6c7('0x6')](this));};Agent[_0xb6c7('0xa')][_0xb6c7('0xb')]=function(){this[_0xb6c7('0x2')][_0xb6c7('0xb')](this[_0xb6c7('0x5')]['bind'](this),this[_0xb6c7('0x7')][_0xb6c7('0x6')](this));};Agent[_0xb6c7('0xa')][_0xb6c7('0x9')]=function(){this[_0xb6c7('0x7')](!![]);};Agent[_0xb6c7('0xa')][_0xb6c7('0x5')]=function(){logger['debug'](_0xb6c7('0xc'),this['squeue']['id'],this['agent']['id']);if(_['isNil'](this[_0xb6c7('0x4')]['agents'][this[_0xb6c7('0x3')]['id']])){logger[_0xb6c7('0xd')](_0xb6c7('0xe'),this[_0xb6c7('0x2')]['id'],this[_0xb6c7('0x3')]['id']);setTimeout(this[_0xb6c7('0xb')][_0xb6c7('0x6')](this),0x3e8);}else{if(this[_0xb6c7('0x1')][_0xb6c7('0xf')]||util[_0xb6c7('0x10')](this[_0xb6c7('0x2')]['id'],this[_0xb6c7('0x4')][_0xb6c7('0x11')][this['agent']['id']],this[_0xb6c7('0x2')][_0xb6c7('0x12')],![])){this['realtime'][_0xb6c7('0x11')][this['agent']['id']][_0xb6c7('0x13')]=!![];this['realtime'][_0xb6c7('0x11')][this['agent']['id']][_0xb6c7('0x14')]=undefined;util[_0xb6c7('0x15')](this['realtime'],this[_0xb6c7('0x1')],this[_0xb6c7('0x3')],this[_0xb6c7('0x2')][_0xb6c7('0x12')]);util[_0xb6c7('0x16')](this[_0xb6c7('0x17')],this['squeue']['id'],this[_0xb6c7('0x4')][_0xb6c7('0x11')][this[_0xb6c7('0x3')]['id']],null,this[_0xb6c7('0x1')]);util['writeLog'](this[_0xb6c7('0x2')]['id'],this[_0xb6c7('0x4')]['agents'][this[_0xb6c7('0x3')]['id']],_0xb6c7('0x18')+(this[_0xb6c7('0x1')][_0xb6c7('0xf')]?':FORCED':''));}else{logger[_0xb6c7('0xd')]('[%s][AGENT]\x20agent\x20%s\x20is\x20not\x20available',this[_0xb6c7('0x2')]['id'],this[_0xb6c7('0x3')]['id']);setTimeout(this[_0xb6c7('0xb')]['bind'](this),0x3e8);}}};Agent['prototype']['handleTimeout']=function(_0x438dc3){if(_[_0xb6c7('0x19')](this[_0xb6c7('0x4')][_0xb6c7('0x11')][this[_0xb6c7('0x3')]['id']])){return logger[_0xb6c7('0xd')](_0xb6c7('0xe'),this[_0xb6c7('0x2')]['id'],this[_0xb6c7('0x3')]['id']);}else{logger[_0xb6c7('0xd')]('[%s][AGENT]\x20timeout\x20with\x20%s',this[_0xb6c7('0x2')]['id'],this['agent']['id']);util[_0xb6c7('0x1a')](this[_0xb6c7('0x17')],this[_0xb6c7('0x2')]['id'],this[_0xb6c7('0x4')][_0xb6c7('0x11')][this['agent']['id']],null,this['routing']);this['realtime'][_0xb6c7('0x11')][this[_0xb6c7('0x3')]['id']]['busy']=![];this[_0xb6c7('0x4')][_0xb6c7('0x11')][this['agent']['id']][_0xb6c7('0x14')]=undefined;util[_0xb6c7('0x1b')](this[_0xb6c7('0x4')],this[_0xb6c7('0x1')],this[_0xb6c7('0x3')],this[_0xb6c7('0x2')]['channel']);util[_0xb6c7('0x1c')](this[_0xb6c7('0x2')]['id'],this[_0xb6c7('0x4')][_0xb6c7('0x11')][this[_0xb6c7('0x3')]['id']],_0x438dc3?_0xb6c7('0x1d'):_0xb6c7('0x1e'));}if(!_0x438dc3){setTimeout(this['push']['bind'](this),0x3e8);}};function agent(_0x3bae95,_0x2c59e1,_0x33afa6,_0x3bbc90){return new Agent(_0x3bae95,_0x2c59e1,_0x33afa6,_0x3bbc90);}module[_0xb6c7('0x1f')]=agent;
\ No newline at end of file