d0793788a5e339389c140b32c327288ff3c06095
[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 _0x6367=['[%s][QUEUE]\x20available\x20again\x20%s','done','mapAgentsId','[%s][QUEUE]\x20try\x20with\x20%s','isNil','info','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','busyQueue','showNotification','writeLog','RINGING','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','[%s][QUEUE]\x20timeout\x20with\x20%s','intervals','hideNotification','TIMEOUT','busy','lodash','uuid','./util','../../../../../config/logger','routing','notificationId','squeue','queue','realtime','push','bind','handleTimeout','timeout','drained','handleDrained','handleRun','prototype','handleCheckReject','isAgentAvailable','agents','agentId','channel'];(function(_0x2820fb,_0x2cd3b5){var _0x99138f=function(_0x3b9361){while(--_0x3b9361){_0x2820fb['push'](_0x2820fb['shift']());}};_0x99138f(++_0x2cd3b5);}(_0x6367,0x170));var _0x7636=function(_0x236d24,_0x29e80a){_0x236d24=_0x236d24-0x0;var _0x1574cf=_0x6367[_0x236d24];return _0x1574cf;};'use strict';var rr=require('rr');var _=require(_0x7636('0x0'));var uuid=require(_0x7636('0x1'));var util=require(_0x7636('0x2'));var logger=require(_0x7636('0x3'))(_0x7636('0x4'));var RRMemory=function(_0x506f43,_0x2d07f7,_0x13301e,_0x44f57f){this[_0x7636('0x5')]=uuid['v4']();this[_0x7636('0x6')]=_0x506f43;this[_0x7636('0x7')]=_0x2d07f7;this[_0x7636('0x8')]=_0x13301e;this[_0x7636('0x4')]=_0x44f57f;this['intervals']={};this[_0x7636('0x6')][_0x7636('0x9')](this['handleRun'][_0x7636('0xa')](this),this[_0x7636('0xb')][_0x7636('0xa')](this),this['module']);this[_0x7636('0x6')]['on'](_0x7636('0xc'),this['handleTimeout']['bind'](this));this[_0x7636('0x6')]['on'](_0x7636('0xd'),this[_0x7636('0xe')][_0x7636('0xa')](this));};RRMemory['prototype'][_0x7636('0x9')]=function(){this[_0x7636('0x6')][_0x7636('0x9')](this[_0x7636('0xf')][_0x7636('0xa')](this),this[_0x7636('0xb')][_0x7636('0xa')](this));};RRMemory['prototype'][_0x7636('0xe')]=function(_0x6b8fff){this[_0x7636('0xb')](!![]);};RRMemory[_0x7636('0x10')][_0x7636('0x11')]=function(_0x439d83){if(util[_0x7636('0x12')](this[_0x7636('0x6')]['id'],this[_0x7636('0x8')][_0x7636('0x13')][this[_0x7636('0x14')]],this['squeue'][_0x7636('0x15')],!![])){logger['info'](_0x7636('0x16'),this[_0x7636('0x6')]['id'],this[_0x7636('0x14')]);clearInterval(this['intervals'][this[_0x7636('0x14')]]);_0x439d83[_0x7636('0x17')]();setTimeout(this[_0x7636('0x9')][_0x7636('0xa')](this),0x3e8);}};RRMemory[_0x7636('0x10')][_0x7636('0xf')]=function(_0x5b7b01){this[_0x7636('0x14')]=rr(this[_0x7636('0x7')][_0x7636('0x18')]);logger['info'](_0x7636('0x19'),this[_0x7636('0x6')]['id'],this[_0x7636('0x14')]);if(_[_0x7636('0x1a')](this[_0x7636('0x8')][_0x7636('0x13')][this[_0x7636('0x14')]])){logger[_0x7636('0x1b')](_0x7636('0x1c'),this[_0x7636('0x6')]['id'],this['agentId']);_0x5b7b01['done']();setTimeout(this[_0x7636('0x9')][_0x7636('0xa')](this),0x3e8);}else{if(util[_0x7636('0x12')](this[_0x7636('0x6')]['id'],this[_0x7636('0x8')][_0x7636('0x13')][this[_0x7636('0x14')]],this[_0x7636('0x6')][_0x7636('0x15')],!![])){this['realtime'][_0x7636('0x13')][this['agentId']]['busy']=!![];this[_0x7636('0x8')]['agents'][this[_0x7636('0x14')]][_0x7636('0x1d')]=this[_0x7636('0x7')]['name'];util[_0x7636('0x1e')](this[_0x7636('0x5')],this[_0x7636('0x6')]['id'],this[_0x7636('0x8')][_0x7636('0x13')][this[_0x7636('0x14')]],this[_0x7636('0x7')],this[_0x7636('0x4')]);util[_0x7636('0x1f')](this[_0x7636('0x6')]['id'],this['realtime'][_0x7636('0x13')][this[_0x7636('0x14')]],_0x7636('0x20'));this['intervals'][this[_0x7636('0x14')]]=setInterval(this['handleCheckReject'][_0x7636('0xa')](this,_0x5b7b01),0x3e8);}else{logger['info'](_0x7636('0x21'),this[_0x7636('0x6')]['id'],this[_0x7636('0x14')]);_0x5b7b01[_0x7636('0x17')]();setTimeout(this[_0x7636('0x9')]['bind'](this),0x3e8);}}};RRMemory[_0x7636('0x10')][_0x7636('0xb')]=function(_0x27b3da){logger[_0x7636('0x1b')](_0x7636('0x22'),this[_0x7636('0x6')]['id'],this[_0x7636('0x14')]);if(_[_0x7636('0x1a')](this['realtime'][_0x7636('0x13')][this[_0x7636('0x14')]])){logger['info'](_0x7636('0x1c'),this[_0x7636('0x6')]['id'],this['agentId']);}else{clearInterval(this[_0x7636('0x23')][this[_0x7636('0x14')]]);util[_0x7636('0x24')](this[_0x7636('0x5')],this[_0x7636('0x6')]['id'],this[_0x7636('0x8')][_0x7636('0x13')][this[_0x7636('0x14')]],this[_0x7636('0x7')],this[_0x7636('0x4')]);util[_0x7636('0x1f')](this[_0x7636('0x6')]['id'],this[_0x7636('0x8')][_0x7636('0x13')][this[_0x7636('0x14')]],_0x7636('0x25'));this[_0x7636('0x8')]['agents'][this[_0x7636('0x14')]][_0x7636('0x26')]=![];this[_0x7636('0x8')][_0x7636('0x13')][this[_0x7636('0x14')]][_0x7636('0x1d')]=undefined;}if(!_0x27b3da){setTimeout(this['push'][_0x7636('0xa')](this),0x3e8);}};function rrmemory(_0x8bd040,_0xbbd88d,_0x2f8bb6,_0x4682ce){return new RRMemory(_0x8bd040,_0xbbd88d,_0x2f8bb6,_0x4682ce);}module['exports']=rrmemory;