f4efe7357a7ded48724c2c991aafcbee4dc0ea41
[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 _0x8f78=['drained','handleDrained','prototype','isAgentAvailable','agentId','channel','info','[%s][QUEUE]\x20available\x20again\x20%s','intervals','done','mapAgentsId','[%s][QUEUE]\x20try\x20with\x20%s','agents','busy','busyQueue','name','showNotification','writeLog','RINGING','handleCheckReject','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','TIMEOUT','exports','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','queue','realtime','squeue','push','handleRun','bind','handleTimeout','module','timeout'];(function(_0x4ed520,_0x21be63){var _0x4415a6=function(_0x14b151){while(--_0x14b151){_0x4ed520['push'](_0x4ed520['shift']());}};_0x4415a6(++_0x21be63);}(_0x8f78,0xd5));var _0x88f7=function(_0x618414,_0x1a7a60){_0x618414=_0x618414-0x0;var _0x21c19a=_0x8f78[_0x618414];return _0x21c19a;};'use strict';var rr=require('rr');var _=require(_0x88f7('0x0'));var uuid=require(_0x88f7('0x1'));var util=require(_0x88f7('0x2'));var logger=require(_0x88f7('0x3'))(_0x88f7('0x4'));var RRMemory=function(_0x539872,_0x183726,_0x166caa,_0xe9927a){this[_0x88f7('0x5')]=uuid['v4']();this['squeue']=_0x539872;this[_0x88f7('0x6')]=_0x183726;this[_0x88f7('0x7')]=_0x166caa;this['routing']=_0xe9927a;this['intervals']={};this[_0x88f7('0x8')][_0x88f7('0x9')](this[_0x88f7('0xa')][_0x88f7('0xb')](this),this[_0x88f7('0xc')][_0x88f7('0xb')](this),this[_0x88f7('0xd')]);this[_0x88f7('0x8')]['on'](_0x88f7('0xe'),this[_0x88f7('0xc')][_0x88f7('0xb')](this));this[_0x88f7('0x8')]['on'](_0x88f7('0xf'),this[_0x88f7('0x10')][_0x88f7('0xb')](this));};RRMemory[_0x88f7('0x11')][_0x88f7('0x9')]=function(){this[_0x88f7('0x8')][_0x88f7('0x9')](this[_0x88f7('0xa')]['bind'](this),this[_0x88f7('0xc')][_0x88f7('0xb')](this));};RRMemory[_0x88f7('0x11')]['handleDrained']=function(_0x2f6af2){this['handleTimeout'](!![]);};RRMemory[_0x88f7('0x11')]['handleCheckReject']=function(_0x3f4349){if(util[_0x88f7('0x12')](this[_0x88f7('0x8')]['id'],this[_0x88f7('0x7')]['agents'][this[_0x88f7('0x13')]],this[_0x88f7('0x8')][_0x88f7('0x14')],!![])){logger[_0x88f7('0x15')](_0x88f7('0x16'),this[_0x88f7('0x8')]['id'],this['agentId']);clearInterval(this[_0x88f7('0x17')][this[_0x88f7('0x13')]]);_0x3f4349[_0x88f7('0x18')]();setTimeout(this[_0x88f7('0x9')]['bind'](this),0x3e8);}};RRMemory[_0x88f7('0x11')][_0x88f7('0xa')]=function(_0x5bdbaa){this[_0x88f7('0x13')]=rr(this[_0x88f7('0x6')][_0x88f7('0x19')]);logger[_0x88f7('0x15')](_0x88f7('0x1a'),this['squeue']['id'],this['agentId']);if(_['isNil'](this[_0x88f7('0x7')][_0x88f7('0x1b')][this[_0x88f7('0x13')]])){logger[_0x88f7('0x15')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x88f7('0x8')]['id'],this[_0x88f7('0x13')]);_0x5bdbaa[_0x88f7('0x18')]();setTimeout(this[_0x88f7('0x9')][_0x88f7('0xb')](this),0x3e8);}else{if(util[_0x88f7('0x12')](this[_0x88f7('0x8')]['id'],this[_0x88f7('0x7')][_0x88f7('0x1b')][this['agentId']],this['squeue']['channel'],!![])){this[_0x88f7('0x7')][_0x88f7('0x1b')][this[_0x88f7('0x13')]][_0x88f7('0x1c')]=!![];this[_0x88f7('0x7')][_0x88f7('0x1b')][this['agentId']][_0x88f7('0x1d')]=this[_0x88f7('0x6')][_0x88f7('0x1e')];util[_0x88f7('0x1f')](this[_0x88f7('0x5')],this['squeue']['id'],this['realtime'][_0x88f7('0x1b')][this['agentId']],this[_0x88f7('0x6')],this[_0x88f7('0x4')]);util[_0x88f7('0x20')](this['squeue']['id'],this[_0x88f7('0x7')][_0x88f7('0x1b')][this[_0x88f7('0x13')]],_0x88f7('0x21'));this[_0x88f7('0x17')][this[_0x88f7('0x13')]]=setInterval(this[_0x88f7('0x22')]['bind'](this,_0x5bdbaa),0x3e8);}else{logger[_0x88f7('0x15')]('[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s',this[_0x88f7('0x8')]['id'],this['agentId']);_0x5bdbaa[_0x88f7('0x18')]();setTimeout(this[_0x88f7('0x9')][_0x88f7('0xb')](this),0x3e8);}}};RRMemory[_0x88f7('0x11')][_0x88f7('0xc')]=function(_0x4e4af9){logger[_0x88f7('0x15')]('[%s][QUEUE]\x20timeout\x20with\x20%s',this[_0x88f7('0x8')]['id'],this[_0x88f7('0x13')]);if(_['isNil'](this[_0x88f7('0x7')][_0x88f7('0x1b')][this[_0x88f7('0x13')]])){logger['info'](_0x88f7('0x23'),this[_0x88f7('0x8')]['id'],this[_0x88f7('0x13')]);}else{clearInterval(this[_0x88f7('0x17')][this[_0x88f7('0x13')]]);util['hideNotification'](this['notificationId'],this[_0x88f7('0x8')]['id'],this[_0x88f7('0x7')]['agents'][this[_0x88f7('0x13')]],this[_0x88f7('0x6')],this[_0x88f7('0x4')]);util[_0x88f7('0x20')](this[_0x88f7('0x8')]['id'],this[_0x88f7('0x7')][_0x88f7('0x1b')][this['agentId']],_0x88f7('0x24'));this[_0x88f7('0x7')][_0x88f7('0x1b')][this[_0x88f7('0x13')]][_0x88f7('0x1c')]=![];this[_0x88f7('0x7')][_0x88f7('0x1b')][this[_0x88f7('0x13')]][_0x88f7('0x1d')]=undefined;}if(!_0x4e4af9){setTimeout(this[_0x88f7('0x9')][_0x88f7('0xb')](this),0x3e8);}};function rrmemory(_0x4c582e,_0x5b730e,_0x3e8193,_0x592e71){return new RRMemory(_0x4c582e,_0x5b730e,_0x3e8193,_0x592e71);}module[_0x88f7('0x25')]=rrmemory;