Built motion from commit (unavailable).|2.5.0
[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 _0xc3bf=['handleDrained','prototype','handleCheckReject','isAgentAvailable','channel','info','[%s][QUEUE]\x20available\x20again\x20%s','agentId','mapAgentsId','[%s][QUEUE]\x20try\x20with\x20%s','isNil','agents','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','done','busy','busyQueue','name','showNotification','writeLog','RINGING','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','[%s][QUEUE]\x20timeout\x20with\x20%s','TIMEOUT','exports','uuid','./util','../../../../../config/logger','routing','notificationId','queue','realtime','intervals','push','handleRun','bind','handleTimeout','module','squeue','timeout','drained'];(function(_0x558eb1,_0x502908){var _0x2f0b9e=function(_0x1e01f1){while(--_0x1e01f1){_0x558eb1['push'](_0x558eb1['shift']());}};_0x2f0b9e(++_0x502908);}(_0xc3bf,0x158));var _0xfc3b=function(_0x4b2a90,_0x27f5ea){_0x4b2a90=_0x4b2a90-0x0;var _0x30bee3=_0xc3bf[_0x4b2a90];return _0x30bee3;};'use strict';var rr=require('rr');var _=require('lodash');var uuid=require(_0xfc3b('0x0'));var util=require(_0xfc3b('0x1'));var logger=require(_0xfc3b('0x2'))(_0xfc3b('0x3'));var RRMemory=function(_0x132297,_0x20f20b,_0x3b473b,_0x3298b2){this[_0xfc3b('0x4')]=uuid['v4']();this['squeue']=_0x132297;this[_0xfc3b('0x5')]=_0x20f20b;this[_0xfc3b('0x6')]=_0x3b473b;this[_0xfc3b('0x3')]=_0x3298b2;this[_0xfc3b('0x7')]={};this['squeue'][_0xfc3b('0x8')](this[_0xfc3b('0x9')][_0xfc3b('0xa')](this),this[_0xfc3b('0xb')]['bind'](this),this[_0xfc3b('0xc')]);this[_0xfc3b('0xd')]['on'](_0xfc3b('0xe'),this['handleTimeout'][_0xfc3b('0xa')](this));this[_0xfc3b('0xd')]['on'](_0xfc3b('0xf'),this[_0xfc3b('0x10')][_0xfc3b('0xa')](this));};RRMemory[_0xfc3b('0x11')][_0xfc3b('0x8')]=function(){this[_0xfc3b('0xd')][_0xfc3b('0x8')](this[_0xfc3b('0x9')][_0xfc3b('0xa')](this),this[_0xfc3b('0xb')]['bind'](this));};RRMemory[_0xfc3b('0x11')][_0xfc3b('0x10')]=function(_0x16038f){this['handleTimeout'](!![]);};RRMemory[_0xfc3b('0x11')][_0xfc3b('0x12')]=function(_0x5999e2){if(util[_0xfc3b('0x13')](this[_0xfc3b('0xd')]['id'],this[_0xfc3b('0x6')]['agents'][this['agentId']],this['squeue'][_0xfc3b('0x14')],!![])){logger[_0xfc3b('0x15')](_0xfc3b('0x16'),this[_0xfc3b('0xd')]['id'],this[_0xfc3b('0x17')]);clearInterval(this[_0xfc3b('0x7')][this[_0xfc3b('0x17')]]);_0x5999e2['done']();setTimeout(this[_0xfc3b('0x8')][_0xfc3b('0xa')](this),0x3e8);}};RRMemory[_0xfc3b('0x11')][_0xfc3b('0x9')]=function(_0x2954eb){this['agentId']=rr(this[_0xfc3b('0x5')][_0xfc3b('0x18')]);logger['info'](_0xfc3b('0x19'),this[_0xfc3b('0xd')]['id'],this[_0xfc3b('0x17')]);if(_[_0xfc3b('0x1a')](this[_0xfc3b('0x6')][_0xfc3b('0x1b')][this['agentId']])){logger[_0xfc3b('0x15')](_0xfc3b('0x1c'),this[_0xfc3b('0xd')]['id'],this[_0xfc3b('0x17')]);_0x2954eb[_0xfc3b('0x1d')]();setTimeout(this[_0xfc3b('0x8')][_0xfc3b('0xa')](this),0x3e8);}else{if(util[_0xfc3b('0x13')](this[_0xfc3b('0xd')]['id'],this[_0xfc3b('0x6')][_0xfc3b('0x1b')][this[_0xfc3b('0x17')]],this[_0xfc3b('0xd')][_0xfc3b('0x14')],!![])){this[_0xfc3b('0x6')][_0xfc3b('0x1b')][this[_0xfc3b('0x17')]][_0xfc3b('0x1e')]=!![];this[_0xfc3b('0x6')][_0xfc3b('0x1b')][this[_0xfc3b('0x17')]][_0xfc3b('0x1f')]=this['queue'][_0xfc3b('0x20')];util[_0xfc3b('0x21')](this[_0xfc3b('0x4')],this[_0xfc3b('0xd')]['id'],this[_0xfc3b('0x6')][_0xfc3b('0x1b')][this['agentId']],this[_0xfc3b('0x5')],this['routing']);util[_0xfc3b('0x22')](this[_0xfc3b('0xd')]['id'],this['realtime'][_0xfc3b('0x1b')][this[_0xfc3b('0x17')]],_0xfc3b('0x23'));this[_0xfc3b('0x7')][this[_0xfc3b('0x17')]]=setInterval(this[_0xfc3b('0x12')]['bind'](this,_0x2954eb),0x3e8);}else{logger[_0xfc3b('0x15')](_0xfc3b('0x24'),this[_0xfc3b('0xd')]['id'],this[_0xfc3b('0x17')]);_0x2954eb['done']();setTimeout(this[_0xfc3b('0x8')][_0xfc3b('0xa')](this),0x3e8);}}};RRMemory[_0xfc3b('0x11')][_0xfc3b('0xb')]=function(_0x2310a6){logger[_0xfc3b('0x15')](_0xfc3b('0x25'),this[_0xfc3b('0xd')]['id'],this[_0xfc3b('0x17')]);if(_[_0xfc3b('0x1a')](this[_0xfc3b('0x6')]['agents'][this[_0xfc3b('0x17')]])){logger['info'](_0xfc3b('0x1c'),this['squeue']['id'],this[_0xfc3b('0x17')]);}else{clearInterval(this['intervals'][this[_0xfc3b('0x17')]]);util['hideNotification'](this['notificationId'],this[_0xfc3b('0xd')]['id'],this[_0xfc3b('0x6')][_0xfc3b('0x1b')][this[_0xfc3b('0x17')]],this['queue'],this['routing']);util['writeLog'](this[_0xfc3b('0xd')]['id'],this[_0xfc3b('0x6')][_0xfc3b('0x1b')][this[_0xfc3b('0x17')]],_0xfc3b('0x26'));this['realtime'][_0xfc3b('0x1b')][this[_0xfc3b('0x17')]][_0xfc3b('0x1e')]=![];this['realtime'][_0xfc3b('0x1b')][this[_0xfc3b('0x17')]][_0xfc3b('0x1f')]=undefined;}if(!_0x2310a6){setTimeout(this[_0xfc3b('0x8')][_0xfc3b('0xa')](this),0x3e8);}};function rrmemory(_0x47a444,_0x11f758,_0x24af2e,_0x4760fb){return new RRMemory(_0x47a444,_0x11f758,_0x24af2e,_0x4760fb);}module[_0xfc3b('0x27')]=rrmemory;