f2297e6d9fb566e2601c8ad60a17429b87f8e6d4
[motion2.git] / server / services / routing / server / applications / strategy / beepall.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 _0xaf85=['STOP','TIMEOUT','busy','removeWaitingNotification','channel','exports','lodash','uuid','./util','notificationId','squeue','queue','realtime','routing','bind','handleTimeout','handleDrained','prototype','push','handleRun','isNil','Agents','length','agents','debug','[%s][QUEUE]\x20agent\x20skipped,\x20unknown\x20id\x20%s','isAgentAvailable','writeLog','busyQueue','saveWaitingNotification','showNotification','[%s][QUEUE]\x20ALL\x20AGENTS\x20ARE\x20BUSY','[%s][QUEUE]\x20EMPTY','hideNotification'];(function(_0x34bc94,_0x74f0fd){var _0xee41e7=function(_0x424111){while(--_0x424111){_0x34bc94['push'](_0x34bc94['shift']());}};_0xee41e7(++_0x74f0fd);}(_0xaf85,0xb0));var _0x5af8=function(_0x380575,_0xc72d46){_0x380575=_0x380575-0x0;var _0x15080a=_0xaf85[_0x380575];return _0x15080a;};'use strict';var _=require(_0x5af8('0x0'));var uuid=require(_0x5af8('0x1'));var util=require(_0x5af8('0x2'));var logger=require('../../../../../config/logger')('routing');var Beepall=function(_0x4d2f03,_0x3c0e0e,_0x23e6db,_0x25aebf){this[_0x5af8('0x3')]=uuid['v4']();this[_0x5af8('0x4')]=_0x4d2f03;this[_0x5af8('0x5')]=_0x3c0e0e;this[_0x5af8('0x6')]=_0x23e6db;this[_0x5af8('0x7')]=_0x25aebf;this['squeue']['push'](this['handleRun'][_0x5af8('0x8')](this),this[_0x5af8('0x9')][_0x5af8('0x8')](this));this[_0x5af8('0x4')]['on']('timeout',this[_0x5af8('0x9')][_0x5af8('0x8')](this));this[_0x5af8('0x4')]['on']('drained',this[_0x5af8('0xa')]['bind'](this));};Beepall[_0x5af8('0xb')][_0x5af8('0xc')]=function(){this[_0x5af8('0x4')][_0x5af8('0xc')](this[_0x5af8('0xd')]['bind'](this),this['handleTimeout'][_0x5af8('0x8')](this));};Beepall['prototype'][_0x5af8('0xa')]=function(){this[_0x5af8('0x9')](!![]);};Beepall[_0x5af8('0xb')][_0x5af8('0xd')]=function(){var _0xd393f8=!![];if(!_['isNil'](this[_0x5af8('0x5')])&&!_[_0x5af8('0xe')](this['queue'][_0x5af8('0xf')])&&this[_0x5af8('0x5')][_0x5af8('0xf')][_0x5af8('0x10')]>0x0){for(var _0x4f19c7=0x0,_0x3d7aa6;_0x4f19c7<this[_0x5af8('0x5')][_0x5af8('0xf')][_0x5af8('0x10')];_0x4f19c7+=0x1){_0x3d7aa6=this[_0x5af8('0x5')][_0x5af8('0xf')][_0x4f19c7]['id'];if(_[_0x5af8('0xe')](this[_0x5af8('0x6')][_0x5af8('0x11')][_0x3d7aa6])){logger[_0x5af8('0x12')](_0x5af8('0x13'),this[_0x5af8('0x4')]['id'],_0x3d7aa6);}else{if(util[_0x5af8('0x14')](this['squeue']['id'],this[_0x5af8('0x6')][_0x5af8('0x11')][_0x3d7aa6],this[_0x5af8('0x4')]['channel'],!![])){_0xd393f8=![];util[_0x5af8('0x15')](this[_0x5af8('0x4')]['id'],this['realtime']['agents'][_0x3d7aa6],'RINGING');this[_0x5af8('0x6')][_0x5af8('0x11')][_0x3d7aa6]['busy']=!![];this[_0x5af8('0x6')][_0x5af8('0x11')][_0x3d7aa6][_0x5af8('0x16')]=this[_0x5af8('0x5')]['name'];util[_0x5af8('0x17')](this[_0x5af8('0x6')],this[_0x5af8('0x7')],this[_0x5af8('0x5')][_0x5af8('0xf')][_0x4f19c7],this[_0x5af8('0x4')]['channel']);util[_0x5af8('0x18')](this[_0x5af8('0x3')],this[_0x5af8('0x4')]['id'],this[_0x5af8('0x6')][_0x5af8('0x11')][_0x3d7aa6],this[_0x5af8('0x5')],this[_0x5af8('0x7')]);}}}if(_0xd393f8){logger[_0x5af8('0x12')](_0x5af8('0x19'),this[_0x5af8('0x4')]['id']);setTimeout(this[_0x5af8('0xc')][_0x5af8('0x8')](this),0x3e8);}}else{logger[_0x5af8('0x12')](_0x5af8('0x1a'),this[_0x5af8('0x4')]['id']);setTimeout(this['push'][_0x5af8('0x8')](this),0x3e8);}};Beepall[_0x5af8('0xb')]['handleTimeout']=function(_0x2e89b2){if(!_[_0x5af8('0xe')](this[_0x5af8('0x5')])&&!_[_0x5af8('0xe')](this[_0x5af8('0x5')][_0x5af8('0xf')])){for(var _0x334d45=0x0,_0x18473f;_0x334d45<this[_0x5af8('0x5')][_0x5af8('0xf')][_0x5af8('0x10')];_0x334d45+=0x1){_0x18473f=this['queue'][_0x5af8('0xf')][_0x334d45]['id'];if(_['isNil'](this[_0x5af8('0x6')]['agents'][_0x18473f])){logger[_0x5af8('0x12')](_0x5af8('0x13'),this[_0x5af8('0x4')]['id'],_0x18473f);}else{util[_0x5af8('0x1b')](this[_0x5af8('0x3')],this['squeue']['id'],this[_0x5af8('0x6')][_0x5af8('0x11')][_0x18473f],this['queue'],this['routing']);util[_0x5af8('0x15')](this[_0x5af8('0x4')]['id'],this['realtime']['agents'][_0x18473f],_0x2e89b2?_0x5af8('0x1c'):_0x5af8('0x1d'));this[_0x5af8('0x6')][_0x5af8('0x11')][_0x18473f][_0x5af8('0x1e')]=![];this[_0x5af8('0x6')][_0x5af8('0x11')][_0x18473f]['busyQueue']=undefined;util[_0x5af8('0x1f')](this[_0x5af8('0x6')],this['routing'],this['realtime'][_0x5af8('0x11')][_0x18473f],this[_0x5af8('0x4')][_0x5af8('0x20')]);}}}if(!_0x2e89b2){setTimeout(this['push'][_0x5af8('0x8')](this),0x3e8);}};function beepall(_0x3ce596,_0x341380,_0x3a9911,_0x2855b9){return new Beepall(_0x3ce596,_0x341380,_0x3a9911,_0x2855b9);}module[_0x5af8('0x21')]=beepall;