Built motion from commit (unavailable).|2.4.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 _0x3078=['[%s][QUEUE]\x20try\x20with\x20%s','isNil','busy','busyQueue','showNotification','notificationId','writeLog','RINGING','handleCheckReject','[%s][QUEUE]\x20agent\x20skipped,\x20not\x20available\x20id\x20%s','[%s][QUEUE]\x20timeout\x20with\x20%s','hideNotification','TIMEOUT','exports','uuid','routing','queue','realtime','squeue','push','handleRun','bind','handleTimeout','module','timeout','drained','handleDrained','prototype','isAgentAvailable','agents','channel','info','agentId','intervals','done'];(function(_0xda301e,_0x58de77){var _0x30988d=function(_0x1b6329){while(--_0x1b6329){_0xda301e['push'](_0xda301e['shift']());}};_0x30988d(++_0x58de77);}(_0x3078,0x103));var _0x8307=function(_0x1afeb1,_0x4ef5e7){_0x1afeb1=_0x1afeb1-0x0;var _0x397155=_0x3078[_0x1afeb1];return _0x397155;};'use strict';var rr=require('rr');var _=require('lodash');var uuid=require(_0x8307('0x0'));var util=require('./util');var logger=require('../../../../../config/logger')(_0x8307('0x1'));var RRMemory=function(_0x5e3f61,_0x4e89a6,_0x5edae9,_0x36d503){this['notificationId']=uuid['v4']();this['squeue']=_0x5e3f61;this[_0x8307('0x2')]=_0x4e89a6;this[_0x8307('0x3')]=_0x5edae9;this['routing']=_0x36d503;this['intervals']={};this[_0x8307('0x4')][_0x8307('0x5')](this[_0x8307('0x6')][_0x8307('0x7')](this),this[_0x8307('0x8')][_0x8307('0x7')](this),this[_0x8307('0x9')]);this[_0x8307('0x4')]['on'](_0x8307('0xa'),this['handleTimeout']['bind'](this));this['squeue']['on'](_0x8307('0xb'),this[_0x8307('0xc')][_0x8307('0x7')](this));};RRMemory[_0x8307('0xd')]['push']=function(){this[_0x8307('0x4')]['push'](this['handleRun'][_0x8307('0x7')](this),this['handleTimeout'][_0x8307('0x7')](this));};RRMemory['prototype']['handleDrained']=function(_0x51baee){this[_0x8307('0x8')](!![]);};RRMemory[_0x8307('0xd')]['handleCheckReject']=function(_0x36c371){if(util[_0x8307('0xe')](this['squeue']['id'],this['realtime'][_0x8307('0xf')][this['agentId']],this['squeue'][_0x8307('0x10')],!![])){logger[_0x8307('0x11')]('[%s][QUEUE]\x20available\x20again\x20%s',this[_0x8307('0x4')]['id'],this[_0x8307('0x12')]);clearInterval(this[_0x8307('0x13')][this['agentId']]);_0x36c371[_0x8307('0x14')]();setTimeout(this[_0x8307('0x5')]['bind'](this),0x3e8);}};RRMemory[_0x8307('0xd')]['handleRun']=function(_0x1cb241){this[_0x8307('0x12')]=rr(this[_0x8307('0x2')]['mapAgentsId']);logger[_0x8307('0x11')](_0x8307('0x15'),this[_0x8307('0x4')]['id'],this['agentId']);if(_[_0x8307('0x16')](this[_0x8307('0x3')][_0x8307('0xf')][this[_0x8307('0x12')]])){logger[_0x8307('0x11')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x8307('0x4')]['id'],this[_0x8307('0x12')]);_0x1cb241[_0x8307('0x14')]();setTimeout(this[_0x8307('0x5')]['bind'](this),0x3e8);}else{if(util[_0x8307('0xe')](this['squeue']['id'],this[_0x8307('0x3')][_0x8307('0xf')][this[_0x8307('0x12')]],this[_0x8307('0x4')]['channel'],!![])){this[_0x8307('0x3')][_0x8307('0xf')][this[_0x8307('0x12')]][_0x8307('0x17')]=!![];this[_0x8307('0x3')][_0x8307('0xf')][this[_0x8307('0x12')]][_0x8307('0x18')]=this[_0x8307('0x2')]['name'];util[_0x8307('0x19')](this[_0x8307('0x1a')],this[_0x8307('0x4')]['id'],this['realtime'][_0x8307('0xf')][this[_0x8307('0x12')]],this[_0x8307('0x2')],this[_0x8307('0x1')]);util[_0x8307('0x1b')](this[_0x8307('0x4')]['id'],this[_0x8307('0x3')]['agents'][this['agentId']],_0x8307('0x1c'));this[_0x8307('0x13')][this[_0x8307('0x12')]]=setInterval(this[_0x8307('0x1d')][_0x8307('0x7')](this,_0x1cb241),0x3e8);}else{logger['info'](_0x8307('0x1e'),this[_0x8307('0x4')]['id'],this[_0x8307('0x12')]);_0x1cb241[_0x8307('0x14')]();setTimeout(this[_0x8307('0x5')][_0x8307('0x7')](this),0x3e8);}}};RRMemory['prototype'][_0x8307('0x8')]=function(_0x6fec49){logger[_0x8307('0x11')](_0x8307('0x1f'),this[_0x8307('0x4')]['id'],this['agentId']);if(_[_0x8307('0x16')](this['realtime'][_0x8307('0xf')][this[_0x8307('0x12')]])){logger['info']('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0x8307('0x4')]['id'],this[_0x8307('0x12')]);}else{clearInterval(this[_0x8307('0x13')][this[_0x8307('0x12')]]);util[_0x8307('0x20')](this[_0x8307('0x1a')],this[_0x8307('0x4')]['id'],this[_0x8307('0x3')]['agents'][this[_0x8307('0x12')]],this['queue'],this['routing']);util[_0x8307('0x1b')](this[_0x8307('0x4')]['id'],this[_0x8307('0x3')]['agents'][this[_0x8307('0x12')]],_0x8307('0x21'));this['realtime']['agents'][this[_0x8307('0x12')]][_0x8307('0x17')]=![];this[_0x8307('0x3')][_0x8307('0xf')][this[_0x8307('0x12')]]['busyQueue']=undefined;}if(!_0x6fec49){setTimeout(this[_0x8307('0x5')][_0x8307('0x7')](this),0x3e8);}};function rrmemory(_0x5dfe00,_0x23e7da,_0x46eab1,_0x25c778){return new RRMemory(_0x5dfe00,_0x23e7da,_0x46eab1,_0x25c778);}module[_0x8307('0x22')]=rrmemory;