Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / services / routing / server / applications / strategy / beepall.js
index 7e3a986..317e44d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbdf1=['agents','debug','channel','RINGING','busy','name','saveWaitingNotification','showNotification','notificationId','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','hideNotification','writeLog','STOP','TIMEOUT','busyQueue','lodash','../../../../../config/logger','routing','squeue','queue','realtime','push','handleRun','bind','handleTimeout','timeout','drained','handleDrained','prototype','isNil','Agents','length'];(function(_0x23a29d,_0x25f5a3){var _0x5230ea=function(_0xa508d3){while(--_0xa508d3){_0x23a29d['push'](_0x23a29d['shift']());}};_0x5230ea(++_0x25f5a3);}(_0xbdf1,0x143));var _0x1bdf=function(_0x2269a5,_0x4b7ef6){_0x2269a5=_0x2269a5-0x0;var _0x105d3d=_0xbdf1[_0x2269a5];return _0x105d3d;};'use strict';var _=require(_0x1bdf('0x0'));var uuid=require('uuid');var util=require('./util');var logger=require(_0x1bdf('0x1'))(_0x1bdf('0x2'));var Beepall=function(_0x5c48dc,_0x34b064,_0x36f00a,_0x116bfd){this['notificationId']=uuid['v4']();this[_0x1bdf('0x3')]=_0x5c48dc;this[_0x1bdf('0x4')]=_0x34b064;this[_0x1bdf('0x5')]=_0x36f00a;this['routing']=_0x116bfd;this[_0x1bdf('0x3')][_0x1bdf('0x6')](this[_0x1bdf('0x7')][_0x1bdf('0x8')](this),this[_0x1bdf('0x9')][_0x1bdf('0x8')](this));this[_0x1bdf('0x3')]['on'](_0x1bdf('0xa'),this[_0x1bdf('0x9')]['bind'](this));this[_0x1bdf('0x3')]['on'](_0x1bdf('0xb'),this[_0x1bdf('0xc')]['bind'](this));};Beepall[_0x1bdf('0xd')][_0x1bdf('0x6')]=function(){this['squeue']['push'](this[_0x1bdf('0x7')][_0x1bdf('0x8')](this),this[_0x1bdf('0x9')][_0x1bdf('0x8')](this));};Beepall[_0x1bdf('0xd')]['handleDrained']=function(){this['handleTimeout'](!![]);};Beepall[_0x1bdf('0xd')][_0x1bdf('0x7')]=function(){var _0x1d6fc6=!![];if(!_[_0x1bdf('0xe')](this['queue'])&&!_[_0x1bdf('0xe')](this[_0x1bdf('0x4')]['Agents'])&&this[_0x1bdf('0x4')][_0x1bdf('0xf')]['length']>0x0){for(var _0x38fb30=0x0,_0x4aefbe;_0x38fb30<this[_0x1bdf('0x4')][_0x1bdf('0xf')][_0x1bdf('0x10')];_0x38fb30+=0x1){_0x4aefbe=this[_0x1bdf('0x4')][_0x1bdf('0xf')][_0x38fb30]['id'];if(_['isNil'](this[_0x1bdf('0x5')][_0x1bdf('0x11')][_0x4aefbe])){logger[_0x1bdf('0x12')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x1bdf('0x3')]['id'],_0x4aefbe);}else{if(util['isAgentAvailable'](this[_0x1bdf('0x3')]['id'],this[_0x1bdf('0x5')][_0x1bdf('0x11')][_0x4aefbe],this['squeue'][_0x1bdf('0x13')],!![])){_0x1d6fc6=![];util['writeLog'](this['squeue']['id'],this['realtime'][_0x1bdf('0x11')][_0x4aefbe],_0x1bdf('0x14'));this[_0x1bdf('0x5')][_0x1bdf('0x11')][_0x4aefbe][_0x1bdf('0x15')]=!![];this[_0x1bdf('0x5')][_0x1bdf('0x11')][_0x4aefbe]['busyQueue']=this['queue'][_0x1bdf('0x16')];util[_0x1bdf('0x17')](this[_0x1bdf('0x5')],this[_0x1bdf('0x2')],this[_0x1bdf('0x4')]['Agents'][_0x38fb30],this[_0x1bdf('0x3')]['channel']);util[_0x1bdf('0x18')](this[_0x1bdf('0x19')],this[_0x1bdf('0x3')]['id'],this[_0x1bdf('0x5')]['agents'][_0x4aefbe],this['queue'],this[_0x1bdf('0x2')]);}}}if(_0x1d6fc6){logger[_0x1bdf('0x12')](_0x1bdf('0x1a'),this['squeue']['id']);setTimeout(this['push'][_0x1bdf('0x8')](this),0x3e8);}}else{logger[_0x1bdf('0x12')](_0x1bdf('0x1b'),this['squeue']['id']);setTimeout(this[_0x1bdf('0x6')][_0x1bdf('0x8')](this),0x3e8);}};Beepall[_0x1bdf('0xd')][_0x1bdf('0x9')]=function(_0xc5a3db){if(!_[_0x1bdf('0xe')](this[_0x1bdf('0x4')])&&!_[_0x1bdf('0xe')](this[_0x1bdf('0x4')]['Agents'])){for(var _0x4bb55b=0x0,_0x5c3f90;_0x4bb55b<this[_0x1bdf('0x4')][_0x1bdf('0xf')]['length'];_0x4bb55b+=0x1){_0x5c3f90=this[_0x1bdf('0x4')]['Agents'][_0x4bb55b]['id'];if(_[_0x1bdf('0xe')](this[_0x1bdf('0x5')]['agents'][_0x5c3f90])){logger['debug'](_0x1bdf('0x1c'),this[_0x1bdf('0x3')]['id'],_0x5c3f90);}else{util[_0x1bdf('0x1d')](this[_0x1bdf('0x19')],this[_0x1bdf('0x3')]['id'],this[_0x1bdf('0x5')][_0x1bdf('0x11')][_0x5c3f90],this['queue'],this[_0x1bdf('0x2')]);util[_0x1bdf('0x1e')](this[_0x1bdf('0x3')]['id'],this[_0x1bdf('0x5')][_0x1bdf('0x11')][_0x5c3f90],_0xc5a3db?_0x1bdf('0x1f'):_0x1bdf('0x20'));this['realtime'][_0x1bdf('0x11')][_0x5c3f90][_0x1bdf('0x15')]=![];this[_0x1bdf('0x5')][_0x1bdf('0x11')][_0x5c3f90][_0x1bdf('0x21')]=undefined;util['removeWaitingNotification'](this[_0x1bdf('0x5')],this[_0x1bdf('0x2')],this[_0x1bdf('0x5')][_0x1bdf('0x11')][_0x5c3f90],this[_0x1bdf('0x3')][_0x1bdf('0x13')]);}}}if(!_0xc5a3db){setTimeout(this[_0x1bdf('0x6')][_0x1bdf('0x8')](this),0x3e8);}};function beepall(_0x3482de,_0x2d1824,_0x152623,_0x365432){return new Beepall(_0x3482de,_0x2d1824,_0x152623,_0x365432);}module['exports']=beepall;
\ No newline at end of file
+var _0xd130=['writeLog','TIMEOUT','removeWaitingNotification','exports','lodash','uuid','./util','../../../../../config/logger','notificationId','squeue','realtime','push','bind','handleTimeout','drained','handleDrained','prototype','handleRun','isNil','queue','Agents','length','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','channel','RINGING','busy','busyQueue','name','saveWaitingNotification','[%s][QUEUE]\x20EMPTY','routing'];(function(_0x52e6cd,_0x316291){var _0x1d6d9a=function(_0x570f86){while(--_0x570f86){_0x52e6cd['push'](_0x52e6cd['shift']());}};_0x1d6d9a(++_0x316291);}(_0xd130,0xeb));var _0x0d13=function(_0x5933e3,_0x21f0fa){_0x5933e3=_0x5933e3-0x0;var _0x569bcf=_0xd130[_0x5933e3];return _0x569bcf;};'use strict';var _=require(_0x0d13('0x0'));var uuid=require(_0x0d13('0x1'));var util=require(_0x0d13('0x2'));var logger=require(_0x0d13('0x3'))('routing');var Beepall=function(_0x53753f,_0x451398,_0x1b19c8,_0x1156c6){this[_0x0d13('0x4')]=uuid['v4']();this[_0x0d13('0x5')]=_0x53753f;this['queue']=_0x451398;this[_0x0d13('0x6')]=_0x1b19c8;this['routing']=_0x1156c6;this[_0x0d13('0x5')][_0x0d13('0x7')](this['handleRun'][_0x0d13('0x8')](this),this['handleTimeout'][_0x0d13('0x8')](this));this['squeue']['on']('timeout',this[_0x0d13('0x9')][_0x0d13('0x8')](this));this[_0x0d13('0x5')]['on'](_0x0d13('0xa'),this[_0x0d13('0xb')]['bind'](this));};Beepall[_0x0d13('0xc')]['push']=function(){this[_0x0d13('0x5')][_0x0d13('0x7')](this[_0x0d13('0xd')][_0x0d13('0x8')](this),this[_0x0d13('0x9')][_0x0d13('0x8')](this));};Beepall['prototype'][_0x0d13('0xb')]=function(){this[_0x0d13('0x9')](!![]);};Beepall[_0x0d13('0xc')][_0x0d13('0xd')]=function(){var _0x552bfd=!![];if(!_[_0x0d13('0xe')](this[_0x0d13('0xf')])&&!_['isNil'](this[_0x0d13('0xf')]['Agents'])&&this[_0x0d13('0xf')][_0x0d13('0x10')][_0x0d13('0x11')]>0x0){for(var _0x3bd056=0x0,_0x64e364;_0x3bd056<this[_0x0d13('0xf')][_0x0d13('0x10')][_0x0d13('0x11')];_0x3bd056+=0x1){_0x64e364=this['queue'][_0x0d13('0x10')][_0x3bd056]['id'];if(_[_0x0d13('0xe')](this[_0x0d13('0x6')][_0x0d13('0x12')][_0x64e364])){logger[_0x0d13('0x13')](_0x0d13('0x14'),this[_0x0d13('0x5')]['id'],_0x64e364);}else{if(util['isAgentAvailable'](this[_0x0d13('0x5')]['id'],this[_0x0d13('0x6')][_0x0d13('0x12')][_0x64e364],this[_0x0d13('0x5')][_0x0d13('0x15')],!![])){_0x552bfd=![];util['writeLog'](this[_0x0d13('0x5')]['id'],this['realtime']['agents'][_0x64e364],_0x0d13('0x16'));this[_0x0d13('0x6')][_0x0d13('0x12')][_0x64e364][_0x0d13('0x17')]=!![];this[_0x0d13('0x6')][_0x0d13('0x12')][_0x64e364][_0x0d13('0x18')]=this[_0x0d13('0xf')][_0x0d13('0x19')];util[_0x0d13('0x1a')](this[_0x0d13('0x6')],this['routing'],this[_0x0d13('0xf')][_0x0d13('0x10')][_0x3bd056],this['squeue'][_0x0d13('0x15')]);util['showNotification'](this[_0x0d13('0x4')],this['squeue']['id'],this['realtime'][_0x0d13('0x12')][_0x64e364],this[_0x0d13('0xf')],this['routing']);}}}if(_0x552bfd){logger['debug']('[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY',this[_0x0d13('0x5')]['id']);setTimeout(this[_0x0d13('0x7')][_0x0d13('0x8')](this),0x3e8);}}else{logger[_0x0d13('0x13')](_0x0d13('0x1b'),this[_0x0d13('0x5')]['id']);setTimeout(this[_0x0d13('0x7')][_0x0d13('0x8')](this),0x3e8);}};Beepall['prototype'][_0x0d13('0x9')]=function(_0x3cab0d){if(!_['isNil'](this[_0x0d13('0xf')])&&!_[_0x0d13('0xe')](this[_0x0d13('0xf')][_0x0d13('0x10')])){for(var _0x22d1fd=0x0,_0x70b942;_0x22d1fd<this['queue'][_0x0d13('0x10')][_0x0d13('0x11')];_0x22d1fd+=0x1){_0x70b942=this[_0x0d13('0xf')]['Agents'][_0x22d1fd]['id'];if(_[_0x0d13('0xe')](this[_0x0d13('0x6')][_0x0d13('0x12')][_0x70b942])){logger[_0x0d13('0x13')](_0x0d13('0x14'),this[_0x0d13('0x5')]['id'],_0x70b942);}else{util['hideNotification'](this[_0x0d13('0x4')],this[_0x0d13('0x5')]['id'],this[_0x0d13('0x6')][_0x0d13('0x12')][_0x70b942],this[_0x0d13('0xf')],this[_0x0d13('0x1c')]);util[_0x0d13('0x1d')](this['squeue']['id'],this['realtime'][_0x0d13('0x12')][_0x70b942],_0x3cab0d?'STOP':_0x0d13('0x1e'));this[_0x0d13('0x6')][_0x0d13('0x12')][_0x70b942]['busy']=![];this[_0x0d13('0x6')][_0x0d13('0x12')][_0x70b942]['busyQueue']=undefined;util[_0x0d13('0x1f')](this[_0x0d13('0x6')],this['routing'],this['realtime'][_0x0d13('0x12')][_0x70b942],this[_0x0d13('0x5')][_0x0d13('0x15')]);}}}if(!_0x3cab0d){setTimeout(this[_0x0d13('0x7')][_0x0d13('0x8')](this),0x3e8);}};function beepall(_0x3bda11,_0x4f4a4c,_0x397577,_0x824c9){return new Beepall(_0x3bda11,_0x4f4a4c,_0x397577,_0x824c9);}module[_0x0d13('0x20')]=beepall;
\ No newline at end of file