Built motion from commit (unavailable).|2.5.1
[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 _0xafac=['routing','notificationId','squeue','queue','realtime','intervals','push','handleRun','bind','handleTimeout','module','timeout','drained','handleDrained','prototype','handleCheckReject','agents','agentId','channel','info','[%s][QUEUE]\x20try\x20with\x20%s','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','done','isAgentAvailable','busy','showNotification','writeLog','RINGING','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','[%s][QUEUE]\x20timeout\x20with\x20%s','isNil','hideNotification','TIMEOUT','exports','./util'];(function(_0x397e5f,_0x454c8f){var _0x5302b8=function(_0x1a29ef){while(--_0x1a29ef){_0x397e5f['push'](_0x397e5f['shift']());}};_0x5302b8(++_0x454c8f);}(_0xafac,0x117));var _0xcafa=function(_0x1efc82,_0x10c1ed){_0x1efc82=_0x1efc82-0x0;var _0x1686d8=_0xafac[_0x1efc82];return _0x1686d8;};'use strict';var rr=require('rr');var _=require('lodash');var uuid=require('uuid');var util=require(_0xcafa('0x0'));var logger=require('../../../../../config/logger')(_0xcafa('0x1'));var RRMemory=function(_0x3e0857,_0x96e295,_0x461e21,_0x2a036a){this[_0xcafa('0x2')]=uuid['v4']();this[_0xcafa('0x3')]=_0x3e0857;this[_0xcafa('0x4')]=_0x96e295;this[_0xcafa('0x5')]=_0x461e21;this['routing']=_0x2a036a;this[_0xcafa('0x6')]={};this[_0xcafa('0x3')][_0xcafa('0x7')](this[_0xcafa('0x8')][_0xcafa('0x9')](this),this[_0xcafa('0xa')][_0xcafa('0x9')](this),this[_0xcafa('0xb')]);this[_0xcafa('0x3')]['on'](_0xcafa('0xc'),this['handleTimeout'][_0xcafa('0x9')](this));this[_0xcafa('0x3')]['on'](_0xcafa('0xd'),this[_0xcafa('0xe')][_0xcafa('0x9')](this));};RRMemory[_0xcafa('0xf')][_0xcafa('0x7')]=function(){this[_0xcafa('0x3')][_0xcafa('0x7')](this[_0xcafa('0x8')][_0xcafa('0x9')](this),this[_0xcafa('0xa')][_0xcafa('0x9')](this));};RRMemory[_0xcafa('0xf')][_0xcafa('0xe')]=function(_0x1954ec){this[_0xcafa('0xa')](!![]);};RRMemory[_0xcafa('0xf')][_0xcafa('0x10')]=function(_0x1a6463){if(util['isAgentAvailable'](this[_0xcafa('0x3')]['id'],this[_0xcafa('0x5')][_0xcafa('0x11')][this[_0xcafa('0x12')]],this[_0xcafa('0x3')][_0xcafa('0x13')],!![])){logger[_0xcafa('0x14')]('[%s][QUEUE]\x20available\x20again\x20%s',this[_0xcafa('0x3')]['id'],this[_0xcafa('0x12')]);clearInterval(this[_0xcafa('0x6')][this['agentId']]);_0x1a6463['done']();setTimeout(this[_0xcafa('0x7')][_0xcafa('0x9')](this),0x3e8);}};RRMemory[_0xcafa('0xf')][_0xcafa('0x8')]=function(_0x37c52b){this[_0xcafa('0x12')]=rr(this[_0xcafa('0x4')]['mapAgentsId']);logger[_0xcafa('0x14')](_0xcafa('0x15'),this[_0xcafa('0x3')]['id'],this[_0xcafa('0x12')]);if(_['isNil'](this[_0xcafa('0x5')]['agents'][this['agentId']])){logger[_0xcafa('0x14')](_0xcafa('0x16'),this['squeue']['id'],this[_0xcafa('0x12')]);_0x37c52b[_0xcafa('0x17')]();setTimeout(this[_0xcafa('0x7')][_0xcafa('0x9')](this),0x3e8);}else{if(util[_0xcafa('0x18')](this['squeue']['id'],this['realtime']['agents'][this['agentId']],this['squeue'][_0xcafa('0x13')],!![])){this[_0xcafa('0x5')][_0xcafa('0x11')][this[_0xcafa('0x12')]][_0xcafa('0x19')]=!![];this[_0xcafa('0x5')][_0xcafa('0x11')][this['agentId']]['busyQueue']=this[_0xcafa('0x4')]['name'];util[_0xcafa('0x1a')](this['notificationId'],this[_0xcafa('0x3')]['id'],this[_0xcafa('0x5')]['agents'][this[_0xcafa('0x12')]],this[_0xcafa('0x4')],this[_0xcafa('0x1')]);util[_0xcafa('0x1b')](this['squeue']['id'],this[_0xcafa('0x5')][_0xcafa('0x11')][this[_0xcafa('0x12')]],_0xcafa('0x1c'));this[_0xcafa('0x6')][this['agentId']]=setInterval(this['handleCheckReject']['bind'](this,_0x37c52b),0x3e8);}else{logger[_0xcafa('0x14')](_0xcafa('0x1d'),this[_0xcafa('0x3')]['id'],this['agentId']);_0x37c52b[_0xcafa('0x17')]();setTimeout(this[_0xcafa('0x7')][_0xcafa('0x9')](this),0x3e8);}}};RRMemory[_0xcafa('0xf')][_0xcafa('0xa')]=function(_0xae53b5){logger[_0xcafa('0x14')](_0xcafa('0x1e'),this[_0xcafa('0x3')]['id'],this[_0xcafa('0x12')]);if(_[_0xcafa('0x1f')](this['realtime'][_0xcafa('0x11')][this['agentId']])){logger[_0xcafa('0x14')](_0xcafa('0x16'),this['squeue']['id'],this[_0xcafa('0x12')]);}else{clearInterval(this[_0xcafa('0x6')][this[_0xcafa('0x12')]]);util[_0xcafa('0x20')](this[_0xcafa('0x2')],this['squeue']['id'],this[_0xcafa('0x5')][_0xcafa('0x11')][this[_0xcafa('0x12')]],this[_0xcafa('0x4')],this[_0xcafa('0x1')]);util[_0xcafa('0x1b')](this[_0xcafa('0x3')]['id'],this[_0xcafa('0x5')]['agents'][this[_0xcafa('0x12')]],_0xcafa('0x21'));this[_0xcafa('0x5')][_0xcafa('0x11')][this['agentId']][_0xcafa('0x19')]=![];this[_0xcafa('0x5')]['agents'][this[_0xcafa('0x12')]]['busyQueue']=undefined;}if(!_0xae53b5){setTimeout(this[_0xcafa('0x7')]['bind'](this),0x3e8);}};function rrmemory(_0x293a7d,_0x29bb58,_0x520beb,_0x2475bb){return new RRMemory(_0x293a7d,_0x29bb58,_0x520beb,_0x2475bb);}module[_0xcafa('0x22')]=rrmemory;