Built motion from commit (unavailable).|2.5.4
[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 _0x73fd=['timeout','handleDrained','handleRun','prototype','handleCheckReject','isAgentAvailable','realtime','agentId','info','[%s][QUEUE]\x20available\x20again\x20%s','intervals','done','mapAgentsId','isNil','agents','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','busy','name','showNotification','notificationId','writeLog','[%s][QUEUE]\x20timeout\x20with\x20%s','hideNotification','TIMEOUT','lodash','./util','../../../../../config/logger','squeue','queue','routing','push','handleTimeout','bind','module'];(function(_0x326dc3,_0x5a7b32){var _0x5962f2=function(_0x1f1f3b){while(--_0x1f1f3b){_0x326dc3['push'](_0x326dc3['shift']());}};_0x5962f2(++_0x5a7b32);}(_0x73fd,0x1d2));var _0xd73f=function(_0x1ef48d,_0x203c73){_0x1ef48d=_0x1ef48d-0x0;var _0x450096=_0x73fd[_0x1ef48d];return _0x450096;};'use strict';var rr=require('rr');var _=require(_0xd73f('0x0'));var uuid=require('uuid');var util=require(_0xd73f('0x1'));var logger=require(_0xd73f('0x2'))('routing');var RRMemory=function(_0x2d2318,_0x25cae3,_0x2cf348,_0x370fed){this['notificationId']=uuid['v4']();this[_0xd73f('0x3')]=_0x2d2318;this[_0xd73f('0x4')]=_0x25cae3;this['realtime']=_0x2cf348;this[_0xd73f('0x5')]=_0x370fed;this['intervals']={};this[_0xd73f('0x3')][_0xd73f('0x6')](this['handleRun']['bind'](this),this[_0xd73f('0x7')][_0xd73f('0x8')](this),this[_0xd73f('0x9')]);this['squeue']['on'](_0xd73f('0xa'),this[_0xd73f('0x7')][_0xd73f('0x8')](this));this[_0xd73f('0x3')]['on']('drained',this[_0xd73f('0xb')][_0xd73f('0x8')](this));};RRMemory['prototype'][_0xd73f('0x6')]=function(){this[_0xd73f('0x3')][_0xd73f('0x6')](this[_0xd73f('0xc')]['bind'](this),this[_0xd73f('0x7')]['bind'](this));};RRMemory[_0xd73f('0xd')][_0xd73f('0xb')]=function(_0x4fff87){this['handleTimeout'](!![]);};RRMemory[_0xd73f('0xd')][_0xd73f('0xe')]=function(_0x262691){if(util[_0xd73f('0xf')](this[_0xd73f('0x3')]['id'],this[_0xd73f('0x10')]['agents'][this[_0xd73f('0x11')]],this[_0xd73f('0x3')]['channel'],!![])){logger[_0xd73f('0x12')](_0xd73f('0x13'),this[_0xd73f('0x3')]['id'],this['agentId']);clearInterval(this[_0xd73f('0x14')][this[_0xd73f('0x11')]]);_0x262691[_0xd73f('0x15')]();setTimeout(this['push']['bind'](this),0x3e8);}};RRMemory['prototype']['handleRun']=function(_0xed25a4){this[_0xd73f('0x11')]=rr(this[_0xd73f('0x4')][_0xd73f('0x16')]);logger[_0xd73f('0x12')]('[%s][QUEUE]\x20try\x20with\x20%s',this[_0xd73f('0x3')]['id'],this[_0xd73f('0x11')]);if(_[_0xd73f('0x17')](this['realtime'][_0xd73f('0x18')][this['agentId']])){logger[_0xd73f('0x12')](_0xd73f('0x19'),this[_0xd73f('0x3')]['id'],this['agentId']);_0xed25a4[_0xd73f('0x15')]();setTimeout(this[_0xd73f('0x6')][_0xd73f('0x8')](this),0x3e8);}else{if(util['isAgentAvailable'](this[_0xd73f('0x3')]['id'],this[_0xd73f('0x10')][_0xd73f('0x18')][this[_0xd73f('0x11')]],this[_0xd73f('0x3')]['channel'],!![])){this['realtime'][_0xd73f('0x18')][this[_0xd73f('0x11')]][_0xd73f('0x1a')]=!![];this[_0xd73f('0x10')]['agents'][this[_0xd73f('0x11')]]['busyQueue']=this[_0xd73f('0x4')][_0xd73f('0x1b')];util[_0xd73f('0x1c')](this[_0xd73f('0x1d')],this[_0xd73f('0x3')]['id'],this[_0xd73f('0x10')][_0xd73f('0x18')][this[_0xd73f('0x11')]],this['queue'],this['routing']);util[_0xd73f('0x1e')](this[_0xd73f('0x3')]['id'],this[_0xd73f('0x10')][_0xd73f('0x18')][this[_0xd73f('0x11')]],'RINGING');this['intervals'][this['agentId']]=setInterval(this[_0xd73f('0xe')][_0xd73f('0x8')](this,_0xed25a4),0x3e8);}else{logger[_0xd73f('0x12')]('[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s',this[_0xd73f('0x3')]['id'],this['agentId']);_0xed25a4['done']();setTimeout(this[_0xd73f('0x6')]['bind'](this),0x3e8);}}};RRMemory[_0xd73f('0xd')][_0xd73f('0x7')]=function(_0x376cdf){logger[_0xd73f('0x12')](_0xd73f('0x1f'),this[_0xd73f('0x3')]['id'],this[_0xd73f('0x11')]);if(_[_0xd73f('0x17')](this[_0xd73f('0x10')]['agents'][this[_0xd73f('0x11')]])){logger[_0xd73f('0x12')](_0xd73f('0x19'),this['squeue']['id'],this[_0xd73f('0x11')]);}else{clearInterval(this['intervals'][this[_0xd73f('0x11')]]);util[_0xd73f('0x20')](this[_0xd73f('0x1d')],this[_0xd73f('0x3')]['id'],this[_0xd73f('0x10')][_0xd73f('0x18')][this[_0xd73f('0x11')]],this[_0xd73f('0x4')],this[_0xd73f('0x5')]);util[_0xd73f('0x1e')](this[_0xd73f('0x3')]['id'],this[_0xd73f('0x10')]['agents'][this[_0xd73f('0x11')]],_0xd73f('0x21'));this[_0xd73f('0x10')]['agents'][this[_0xd73f('0x11')]][_0xd73f('0x1a')]=![];this[_0xd73f('0x10')][_0xd73f('0x18')][this[_0xd73f('0x11')]]['busyQueue']=undefined;}if(!_0x376cdf){setTimeout(this[_0xd73f('0x6')][_0xd73f('0x8')](this),0x3e8);}};function rrmemory(_0x4cbcab,_0x309000,_0x42c78a,_0x58b64f){return new RRMemory(_0x4cbcab,_0x309000,_0x42c78a,_0x58b64f);}module['exports']=rrmemory;