Built motion from commit (unavailable).|2.5.11
[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 _0x8542=['handleTimeout','handleDrained','prototype','handleCheckReject','isAgentAvailable','realtime','agents','agentId','[%s][QUEUE]\x20available\x20again\x20%s','intervals','done','mapAgentsId','info','[%s][QUEUE]\x20try\x20with\x20%s','isNil','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','busy','busyQueue','showNotification','writeLog','RINGING','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','[%s][QUEUE]\x20timeout\x20with\x20%s','hideNotification','TIMEOUT','uuid','../../../../../config/logger','routing','notificationId','queue','squeue','push','handleRun','bind','timeout'];(function(_0x3dd698,_0x4bd009){var _0x8bdd64=function(_0x449058){while(--_0x449058){_0x3dd698['push'](_0x3dd698['shift']());}};_0x8bdd64(++_0x4bd009);}(_0x8542,0xa5));var _0x2854=function(_0x3721fb,_0x40333b){_0x3721fb=_0x3721fb-0x0;var _0x212543=_0x8542[_0x3721fb];return _0x212543;};'use strict';var rr=require('rr');var _=require('lodash');var uuid=require(_0x2854('0x0'));var util=require('./util');var logger=require(_0x2854('0x1'))(_0x2854('0x2'));var RRMemory=function(_0x317e1d,_0x354804,_0x353346,_0x559b6c){this[_0x2854('0x3')]=uuid['v4']();this['squeue']=_0x317e1d;this[_0x2854('0x4')]=_0x354804;this['realtime']=_0x353346;this[_0x2854('0x2')]=_0x559b6c;this['intervals']={};this[_0x2854('0x5')][_0x2854('0x6')](this[_0x2854('0x7')][_0x2854('0x8')](this),this['handleTimeout'][_0x2854('0x8')](this),this['module']);this[_0x2854('0x5')]['on'](_0x2854('0x9'),this[_0x2854('0xa')]['bind'](this));this[_0x2854('0x5')]['on']('drained',this[_0x2854('0xb')]['bind'](this));};RRMemory[_0x2854('0xc')][_0x2854('0x6')]=function(){this['squeue'][_0x2854('0x6')](this[_0x2854('0x7')][_0x2854('0x8')](this),this[_0x2854('0xa')][_0x2854('0x8')](this));};RRMemory[_0x2854('0xc')][_0x2854('0xb')]=function(_0x3d8f6d){this[_0x2854('0xa')](!![]);};RRMemory[_0x2854('0xc')][_0x2854('0xd')]=function(_0x2a6789){if(util[_0x2854('0xe')](this[_0x2854('0x5')]['id'],this[_0x2854('0xf')][_0x2854('0x10')][this[_0x2854('0x11')]],this[_0x2854('0x5')]['channel'],!![])){logger['info'](_0x2854('0x12'),this[_0x2854('0x5')]['id'],this[_0x2854('0x11')]);clearInterval(this[_0x2854('0x13')][this[_0x2854('0x11')]]);_0x2a6789[_0x2854('0x14')]();setTimeout(this[_0x2854('0x6')][_0x2854('0x8')](this),0x3e8);}};RRMemory[_0x2854('0xc')][_0x2854('0x7')]=function(_0x2701f9){this[_0x2854('0x11')]=rr(this['queue'][_0x2854('0x15')]);logger[_0x2854('0x16')](_0x2854('0x17'),this['squeue']['id'],this[_0x2854('0x11')]);if(_[_0x2854('0x18')](this[_0x2854('0xf')][_0x2854('0x10')][this[_0x2854('0x11')]])){logger[_0x2854('0x16')](_0x2854('0x19'),this[_0x2854('0x5')]['id'],this[_0x2854('0x11')]);_0x2701f9[_0x2854('0x14')]();setTimeout(this['push'][_0x2854('0x8')](this),0x3e8);}else{if(util[_0x2854('0xe')](this['squeue']['id'],this[_0x2854('0xf')][_0x2854('0x10')][this[_0x2854('0x11')]],this[_0x2854('0x5')]['channel'],!![])){this['realtime'][_0x2854('0x10')][this['agentId']][_0x2854('0x1a')]=!![];this['realtime'][_0x2854('0x10')][this[_0x2854('0x11')]][_0x2854('0x1b')]=this[_0x2854('0x4')]['name'];util[_0x2854('0x1c')](this[_0x2854('0x3')],this['squeue']['id'],this[_0x2854('0xf')][_0x2854('0x10')][this['agentId']],this['queue'],this[_0x2854('0x2')]);util[_0x2854('0x1d')](this[_0x2854('0x5')]['id'],this[_0x2854('0xf')][_0x2854('0x10')][this[_0x2854('0x11')]],_0x2854('0x1e'));this[_0x2854('0x13')][this[_0x2854('0x11')]]=setInterval(this['handleCheckReject'][_0x2854('0x8')](this,_0x2701f9),0x3e8);}else{logger[_0x2854('0x16')](_0x2854('0x1f'),this[_0x2854('0x5')]['id'],this['agentId']);_0x2701f9[_0x2854('0x14')]();setTimeout(this[_0x2854('0x6')][_0x2854('0x8')](this),0x3e8);}}};RRMemory['prototype'][_0x2854('0xa')]=function(_0x3a2159){logger[_0x2854('0x16')](_0x2854('0x20'),this['squeue']['id'],this[_0x2854('0x11')]);if(_['isNil'](this[_0x2854('0xf')]['agents'][this[_0x2854('0x11')]])){logger['info'](_0x2854('0x19'),this[_0x2854('0x5')]['id'],this[_0x2854('0x11')]);}else{clearInterval(this['intervals'][this[_0x2854('0x11')]]);util[_0x2854('0x21')](this['notificationId'],this[_0x2854('0x5')]['id'],this[_0x2854('0xf')][_0x2854('0x10')][this[_0x2854('0x11')]],this[_0x2854('0x4')],this['routing']);util[_0x2854('0x1d')](this[_0x2854('0x5')]['id'],this[_0x2854('0xf')][_0x2854('0x10')][this[_0x2854('0x11')]],_0x2854('0x22'));this['realtime'][_0x2854('0x10')][this[_0x2854('0x11')]]['busy']=![];this[_0x2854('0xf')][_0x2854('0x10')][this[_0x2854('0x11')]][_0x2854('0x1b')]=undefined;}if(!_0x3a2159){setTimeout(this['push'][_0x2854('0x8')](this),0x3e8);}};function rrmemory(_0x495a18,_0x563a70,_0x5d7d08,_0x320b2a){return new RRMemory(_0x495a18,_0x563a70,_0x5d7d08,_0x320b2a);}module['exports']=rrmemory;