78945dfd9436ad2c861a06862a14e7356eca9e2d
[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 _0x0811=['handleDrained','prototype','handleCheckReject','isAgentAvailable','agentId','channel','info','done','[%s][QUEUE]\x20try\x20with\x20%s','isNil','agents','busyQueue','name','showNotification','writeLog','RINGING','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','[%s][QUEUE]\x20timeout\x20with\x20%s','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','busy','lodash','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','intervals','push','handleRun','bind','handleTimeout','module','timeout','drained'];(function(_0x1e3329,_0x162371){var _0x2a8d8d=function(_0x1186f3){while(--_0x1186f3){_0x1e3329['push'](_0x1e3329['shift']());}};_0x2a8d8d(++_0x162371);}(_0x0811,0xe6));var _0x1081=function(_0x37f89c,_0x49a16c){_0x37f89c=_0x37f89c-0x0;var _0x4ebeac=_0x0811[_0x37f89c];return _0x4ebeac;};'use strict';var rr=require('rr');var _=require(_0x1081('0x0'));var uuid=require('uuid');var util=require('./util');var logger=require(_0x1081('0x1'))(_0x1081('0x2'));var RRMemory=function(_0x13852d,_0x50e75a,_0x62d7da,_0x34ac7b){this[_0x1081('0x3')]=uuid['v4']();this[_0x1081('0x4')]=_0x13852d;this[_0x1081('0x5')]=_0x50e75a;this[_0x1081('0x6')]=_0x62d7da;this['routing']=_0x34ac7b;this[_0x1081('0x7')]={};this[_0x1081('0x4')][_0x1081('0x8')](this[_0x1081('0x9')][_0x1081('0xa')](this),this[_0x1081('0xb')]['bind'](this),this[_0x1081('0xc')]);this[_0x1081('0x4')]['on'](_0x1081('0xd'),this[_0x1081('0xb')][_0x1081('0xa')](this));this[_0x1081('0x4')]['on'](_0x1081('0xe'),this[_0x1081('0xf')][_0x1081('0xa')](this));};RRMemory[_0x1081('0x10')][_0x1081('0x8')]=function(){this[_0x1081('0x4')][_0x1081('0x8')](this[_0x1081('0x9')][_0x1081('0xa')](this),this[_0x1081('0xb')][_0x1081('0xa')](this));};RRMemory[_0x1081('0x10')][_0x1081('0xf')]=function(_0xf19aaa){this[_0x1081('0xb')](!![]);};RRMemory[_0x1081('0x10')][_0x1081('0x11')]=function(_0x277776){if(util[_0x1081('0x12')](this['squeue']['id'],this['realtime']['agents'][this[_0x1081('0x13')]],this[_0x1081('0x4')][_0x1081('0x14')],!![])){logger[_0x1081('0x15')]('[%s][QUEUE]\x20available\x20again\x20%s',this[_0x1081('0x4')]['id'],this[_0x1081('0x13')]);clearInterval(this[_0x1081('0x7')][this['agentId']]);_0x277776[_0x1081('0x16')]();setTimeout(this[_0x1081('0x8')][_0x1081('0xa')](this),0x3e8);}};RRMemory['prototype'][_0x1081('0x9')]=function(_0x189136){this[_0x1081('0x13')]=rr(this['queue']['mapAgentsId']);logger[_0x1081('0x15')](_0x1081('0x17'),this[_0x1081('0x4')]['id'],this[_0x1081('0x13')]);if(_[_0x1081('0x18')](this[_0x1081('0x6')][_0x1081('0x19')][this['agentId']])){logger[_0x1081('0x15')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this['squeue']['id'],this['agentId']);_0x189136[_0x1081('0x16')]();setTimeout(this[_0x1081('0x8')][_0x1081('0xa')](this),0x3e8);}else{if(util[_0x1081('0x12')](this[_0x1081('0x4')]['id'],this['realtime'][_0x1081('0x19')][this[_0x1081('0x13')]],this[_0x1081('0x4')]['channel'],!![])){this['realtime'][_0x1081('0x19')][this[_0x1081('0x13')]]['busy']=!![];this[_0x1081('0x6')][_0x1081('0x19')][this['agentId']][_0x1081('0x1a')]=this[_0x1081('0x5')][_0x1081('0x1b')];util[_0x1081('0x1c')](this[_0x1081('0x3')],this[_0x1081('0x4')]['id'],this[_0x1081('0x6')]['agents'][this[_0x1081('0x13')]],this[_0x1081('0x5')],this[_0x1081('0x2')]);util[_0x1081('0x1d')](this['squeue']['id'],this[_0x1081('0x6')][_0x1081('0x19')][this[_0x1081('0x13')]],_0x1081('0x1e'));this[_0x1081('0x7')][this[_0x1081('0x13')]]=setInterval(this[_0x1081('0x11')][_0x1081('0xa')](this,_0x189136),0x3e8);}else{logger[_0x1081('0x15')](_0x1081('0x1f'),this['squeue']['id'],this[_0x1081('0x13')]);_0x189136[_0x1081('0x16')]();setTimeout(this[_0x1081('0x8')]['bind'](this),0x3e8);}}};RRMemory['prototype'][_0x1081('0xb')]=function(_0x3b3987){logger['info'](_0x1081('0x20'),this[_0x1081('0x4')]['id'],this['agentId']);if(_[_0x1081('0x18')](this[_0x1081('0x6')][_0x1081('0x19')][this['agentId']])){logger[_0x1081('0x15')](_0x1081('0x21'),this[_0x1081('0x4')]['id'],this['agentId']);}else{clearInterval(this[_0x1081('0x7')][this[_0x1081('0x13')]]);util['hideNotification'](this['notificationId'],this[_0x1081('0x4')]['id'],this[_0x1081('0x6')][_0x1081('0x19')][this[_0x1081('0x13')]],this[_0x1081('0x5')],this['routing']);util['writeLog'](this[_0x1081('0x4')]['id'],this[_0x1081('0x6')][_0x1081('0x19')][this[_0x1081('0x13')]],'TIMEOUT');this[_0x1081('0x6')][_0x1081('0x19')][this['agentId']][_0x1081('0x22')]=![];this['realtime'][_0x1081('0x19')][this[_0x1081('0x13')]]['busyQueue']=undefined;}if(!_0x3b3987){setTimeout(this[_0x1081('0x8')][_0x1081('0xa')](this),0x3e8);}};function rrmemory(_0x6dd4d,_0x561db7,_0x5cf281,_0x48de27){return new RRMemory(_0x6dd4d,_0x561db7,_0x5cf281,_0x48de27);}module['exports']=rrmemory;