Built motion from commit (unavailable).|2.0.76
[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 _0x4cbf=['agentId','mapAgentsId','info','realtime','agents','channel','writeLog','RINGING','busy','name','showNotification','isNil','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','busyQueue','hideNotification','lodash','uuid','./util','routing','notificationId','squeue','queue','length','floor','qtimeout','atimeout','module','handleRun','handleTimeout','bind','drained','push','done','prototype'];(function(_0x15f607,_0x230ef5){var _0x11205d=function(_0x1f8a20){while(--_0x1f8a20){_0x15f607['push'](_0x15f607['shift']());}};_0x11205d(++_0x230ef5);}(_0x4cbf,0xfd));var _0xf4cb=function(_0x3ea913,_0x255df2){_0x3ea913=_0x3ea913-0x0;var _0x2b4f28=_0x4cbf[_0x3ea913];return _0x2b4f28;};'use strict';var rr=require('rr');var _=require(_0xf4cb('0x0'));var uuid=require(_0xf4cb('0x1'));var util=require(_0xf4cb('0x2'));var logger=require('../../../../../config/logger')(_0xf4cb('0x3'));var RRMemory=function(_0x223d6d,_0x20c4ce,_0xb2197,_0x44f635){this[_0xf4cb('0x4')]=uuid['v4']();this[_0xf4cb('0x5')]=_0x223d6d;this[_0xf4cb('0x6')]=_0x20c4ce;this['realtime']=_0xb2197;this[_0xf4cb('0x3')]=_0x44f635;this[_0xf4cb('0x7')]=Math[_0xf4cb('0x8')](this[_0xf4cb('0x5')][_0xf4cb('0x9')]/this['squeue'][_0xf4cb('0xa')]);this[_0xf4cb('0xb')]=this['squeue'][_0xf4cb('0x9')]%this[_0xf4cb('0x5')][_0xf4cb('0xa')];for(var _0x46eba8=0x0;_0x46eba8<this[_0xf4cb('0x7')];_0x46eba8+=0x1){this['squeue']['push'](this[_0xf4cb('0xc')]['bind'](this),this[_0xf4cb('0xd')][_0xf4cb('0xe')](this));}this[_0xf4cb('0x5')]['push'](this[_0xf4cb('0xc')][_0xf4cb('0xe')](this),this['handleTimeout']['bind'](this),this[_0xf4cb('0xb')]);this['squeue']['on'](_0xf4cb('0xf'),this['handleTimeout'][_0xf4cb('0xe')](this));};RRMemory['prototype'][_0xf4cb('0x10')]=function(){this['squeue']['push'](this['handleRun']['bind'](this),this['handleTimeout'][_0xf4cb('0xe')](this));};RRMemory['prototype'][_0xf4cb('0x11')]=function(_0xc7723){if(_0xc7723){setTimeout(this[_0xf4cb('0x10')]['bind'](this),0xc8);_0xc7723[_0xf4cb('0x11')]();}};RRMemory[_0xf4cb('0x12')][_0xf4cb('0xc')]=function(_0x46f778){this[_0xf4cb('0x13')]=rr(this[_0xf4cb('0x6')][_0xf4cb('0x14')]);logger[_0xf4cb('0x15')]('[%s][QUEUE]\x20try\x20with\x20%s',this[_0xf4cb('0x5')]['id'],this[_0xf4cb('0x13')]);if(_['isNil'](this[_0xf4cb('0x16')]['agents'][this['agentId']])){logger[_0xf4cb('0x15')]('[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s',this[_0xf4cb('0x5')]['id'],this['agentId']);this[_0xf4cb('0x11')](_0x46f778);}else{if(util['isAgentAvailable'](this[_0xf4cb('0x5')]['id'],this['realtime'][_0xf4cb('0x17')][this[_0xf4cb('0x13')]],this[_0xf4cb('0x5')][_0xf4cb('0x18')],!![])){util[_0xf4cb('0x19')](this['squeue']['id'],this[_0xf4cb('0x16')][_0xf4cb('0x17')][this[_0xf4cb('0x13')]],_0xf4cb('0x1a'));this[_0xf4cb('0x16')][_0xf4cb('0x17')][this[_0xf4cb('0x13')]][_0xf4cb('0x1b')]=!![];this[_0xf4cb('0x16')][_0xf4cb('0x17')][this[_0xf4cb('0x13')]]['busyQueue']=this[_0xf4cb('0x6')][_0xf4cb('0x1c')];util[_0xf4cb('0x1d')](this[_0xf4cb('0x4')],this[_0xf4cb('0x5')]['id'],this[_0xf4cb('0x16')]['agents'][this[_0xf4cb('0x13')]],this[_0xf4cb('0x6')],this['routing']);}else{this['done'](_0x46f778);}}};RRMemory['prototype']['handleTimeout']=function(){logger[_0xf4cb('0x15')]('[%s][QUEUE]\x20timeout\x20with\x20%s',this[_0xf4cb('0x5')]['id'],this[_0xf4cb('0x13')]);if(_[_0xf4cb('0x1e')](this[_0xf4cb('0x16')]['agents'][this[_0xf4cb('0x13')]])){logger[_0xf4cb('0x15')](_0xf4cb('0x1f'),this['squeue']['id'],this[_0xf4cb('0x13')]);}else{util['writeLog'](this[_0xf4cb('0x5')]['id'],this[_0xf4cb('0x16')][_0xf4cb('0x17')][this[_0xf4cb('0x13')]],'TIMEOUT');this[_0xf4cb('0x16')]['agents'][this[_0xf4cb('0x13')]]['busy']=![];this[_0xf4cb('0x16')][_0xf4cb('0x17')][this['agentId']][_0xf4cb('0x20')]=undefined;util[_0xf4cb('0x21')](this[_0xf4cb('0x4')],this[_0xf4cb('0x5')]['id'],this[_0xf4cb('0x16')]['agents'][this['agentId']],this['queue'],this['routing']);}};function rrmemory(_0x3a0d51,_0x259169,_0x3d85c0,_0x4d8b21){return new RRMemory(_0x3a0d51,_0x259169,_0x3d85c0,_0x4d8b21);}module['exports']=rrmemory;