Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / services / routing / server / applications / strategy / rrmemory.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x3b7a=['name','showNotification','writeLog','RINGING','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','done','hideNotification','TIMEOUT','busy','exports','lodash','./util','../../../../../config/logger','routing','notificationId','queue','realtime','intervals','push','handleRun','handleTimeout','squeue','timeout','bind','handleDrained','prototype','handleCheckReject','isAgentAvailable','agents','agentId','channel','info','[%s][QUEUE]\x20available\x20again\x20%s','mapAgentsId','isNil','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','busyQueue'];(function(_0x55b7f8,_0x1ff7fe){var _0x2652af=function(_0x51aa82){while(--_0x51aa82){_0x55b7f8['push'](_0x55b7f8['shift']());}};_0x2652af(++_0x1ff7fe);}(_0x3b7a,0x10d));var _0xa3b7=function(_0x2c91e9,_0x2fb965){_0x2c91e9=_0x2c91e9-0x0;var _0x13f0ff=_0x3b7a[_0x2c91e9];return _0x13f0ff;};'use strict';var rr=require('rr');var _=require(_0xa3b7('0x0'));var uuid=require('uuid');var util=require(_0xa3b7('0x1'));var logger=require(_0xa3b7('0x2'))(_0xa3b7('0x3'));var RRMemory=function(_0x492069,_0x3ecfa7,_0x39fbf6,_0x6d174f){this[_0xa3b7('0x4')]=uuid['v4']();this['squeue']=_0x492069;this[_0xa3b7('0x5')]=_0x3ecfa7;this[_0xa3b7('0x6')]=_0x39fbf6;this[_0xa3b7('0x3')]=_0x6d174f;this[_0xa3b7('0x7')]={};this['squeue'][_0xa3b7('0x8')](this[_0xa3b7('0x9')]['bind'](this),this[_0xa3b7('0xa')]['bind'](this),this['module']);this[_0xa3b7('0xb')]['on'](_0xa3b7('0xc'),this[_0xa3b7('0xa')][_0xa3b7('0xd')](this));this[_0xa3b7('0xb')]['on']('drained',this[_0xa3b7('0xe')][_0xa3b7('0xd')](this));};RRMemory['prototype'][_0xa3b7('0x8')]=function(){this[_0xa3b7('0xb')]['push'](this['handleRun']['bind'](this),this[_0xa3b7('0xa')][_0xa3b7('0xd')](this));};RRMemory[_0xa3b7('0xf')][_0xa3b7('0xe')]=function(_0x10726c){this[_0xa3b7('0xa')](!![]);};RRMemory[_0xa3b7('0xf')][_0xa3b7('0x10')]=function(_0x47770a){if(util[_0xa3b7('0x11')](this['squeue']['id'],this['realtime'][_0xa3b7('0x12')][this[_0xa3b7('0x13')]],this[_0xa3b7('0xb')][_0xa3b7('0x14')],!![])){logger[_0xa3b7('0x15')](_0xa3b7('0x16'),this['squeue']['id'],this[_0xa3b7('0x13')]);clearInterval(this[_0xa3b7('0x7')][this[_0xa3b7('0x13')]]);_0x47770a['done']();setTimeout(this[_0xa3b7('0x8')][_0xa3b7('0xd')](this),0x3e8);}};RRMemory[_0xa3b7('0xf')][_0xa3b7('0x9')]=function(_0x42eda1){this['agentId']=rr(this[_0xa3b7('0x5')][_0xa3b7('0x17')]);logger[_0xa3b7('0x15')]('[%s][QUEUE]\x20try\x20with\x20%s',this[_0xa3b7('0xb')]['id'],this[_0xa3b7('0x13')]);if(_[_0xa3b7('0x18')](this[_0xa3b7('0x6')][_0xa3b7('0x12')][this[_0xa3b7('0x13')]])){logger[_0xa3b7('0x15')](_0xa3b7('0x19'),this[_0xa3b7('0xb')]['id'],this[_0xa3b7('0x13')]);_0x42eda1['done']();setTimeout(this[_0xa3b7('0x8')]['bind'](this),0x3e8);}else{if(util['isAgentAvailable'](this[_0xa3b7('0xb')]['id'],this[_0xa3b7('0x6')][_0xa3b7('0x12')][this[_0xa3b7('0x13')]],this['squeue']['channel'],!![])){this[_0xa3b7('0x6')][_0xa3b7('0x12')][this[_0xa3b7('0x13')]]['busy']=!![];this[_0xa3b7('0x6')]['agents'][this[_0xa3b7('0x13')]][_0xa3b7('0x1a')]=this['queue'][_0xa3b7('0x1b')];util[_0xa3b7('0x1c')](this[_0xa3b7('0x4')],this[_0xa3b7('0xb')]['id'],this[_0xa3b7('0x6')]['agents'][this[_0xa3b7('0x13')]],this[_0xa3b7('0x5')],this[_0xa3b7('0x3')]);util[_0xa3b7('0x1d')](this['squeue']['id'],this[_0xa3b7('0x6')]['agents'][this[_0xa3b7('0x13')]],_0xa3b7('0x1e'));this[_0xa3b7('0x7')][this['agentId']]=setInterval(this[_0xa3b7('0x10')][_0xa3b7('0xd')](this,_0x42eda1),0x3e8);}else{logger[_0xa3b7('0x15')](_0xa3b7('0x1f'),this[_0xa3b7('0xb')]['id'],this['agentId']);_0x42eda1[_0xa3b7('0x20')]();setTimeout(this[_0xa3b7('0x8')][_0xa3b7('0xd')](this),0x3e8);}}};RRMemory['prototype']['handleTimeout']=function(_0x46516d){logger['info']('[%s][QUEUE]\x20timeout\x20with\x20%s',this['squeue']['id'],this[_0xa3b7('0x13')]);if(_[_0xa3b7('0x18')](this[_0xa3b7('0x6')][_0xa3b7('0x12')][this[_0xa3b7('0x13')]])){logger['info'](_0xa3b7('0x19'),this['squeue']['id'],this[_0xa3b7('0x13')]);}else{clearInterval(this[_0xa3b7('0x7')][this[_0xa3b7('0x13')]]);util[_0xa3b7('0x21')](this['notificationId'],this['squeue']['id'],this['realtime'][_0xa3b7('0x12')][this[_0xa3b7('0x13')]],this['queue'],this[_0xa3b7('0x3')]);util[_0xa3b7('0x1d')](this['squeue']['id'],this[_0xa3b7('0x6')][_0xa3b7('0x12')][this[_0xa3b7('0x13')]],_0xa3b7('0x22'));this[_0xa3b7('0x6')]['agents'][this['agentId']][_0xa3b7('0x23')]=![];this[_0xa3b7('0x6')][_0xa3b7('0x12')][this[_0xa3b7('0x13')]]['busyQueue']=undefined;}if(!_0x46516d){setTimeout(this[_0xa3b7('0x8')]['bind'](this),0x3e8);}};function rrmemory(_0xc98a1a,_0x1a3072,_0x17466a,_0x4c2e4d){return new RRMemory(_0xc98a1a,_0x1a3072,_0x17466a,_0x4c2e4d);}module[_0xa3b7('0x24')]=rrmemory;