Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / services / routing / server / applications / strategy / agent.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 _0x4b79=['bind','handleTimeout','timeout','drained','prototype','info','[%s][AGENT]\x20try\x20with\x20%s','isNil','realtime','agents','[%s][AGENT]\x20agent\x20skipped,\x20unknown\x20id\x20%s','push','routing','forcedOwnership','isAgentAvailable','busy','showNotification','writeLog','RINGING',':FORCED','[%s][AGENT]\x20agent\x20%s\x20is\x20not\x20available','[%s][AGENT]\x20timeout\x20with\x20%s','hideNotification','STOP','exports','lodash','uuid','./util','../../../../../config/logger','notificationId','squeue','agent','handleRun'];(function(_0x3fba9f,_0x3b7b9b){var _0x192cf1=function(_0x557290){while(--_0x557290){_0x3fba9f['push'](_0x3fba9f['shift']());}};_0x192cf1(++_0x3b7b9b);}(_0x4b79,0xdf));var _0x94b7=function(_0x44cf50,_0x5bbab4){_0x44cf50=_0x44cf50-0x0;var _0x46461c=_0x4b79[_0x44cf50];return _0x46461c;};'use strict';var _=require(_0x94b7('0x0'));var uuid=require(_0x94b7('0x1'));var util=require(_0x94b7('0x2'));var logger=require(_0x94b7('0x3'))('routing');var Agent=function(_0xf688f0,_0x3cd09d,_0x256c3e,_0x40479c){this[_0x94b7('0x4')]=uuid['v4']();this[_0x94b7('0x5')]=_0xf688f0;this[_0x94b7('0x6')]=_0x3cd09d;this['realtime']=_0x256c3e;this['routing']=_0x40479c;this[_0x94b7('0x5')]['push'](this[_0x94b7('0x7')][_0x94b7('0x8')](this),this[_0x94b7('0x9')][_0x94b7('0x8')](this));this[_0x94b7('0x5')]['on'](_0x94b7('0xa'),this['handleTimeout']['bind'](this));this[_0x94b7('0x5')]['on'](_0x94b7('0xb'),this['handleDrained'][_0x94b7('0x8')](this));};Agent['prototype']['push']=function(){this[_0x94b7('0x5')]['push'](this[_0x94b7('0x7')]['bind'](this),this[_0x94b7('0x9')][_0x94b7('0x8')](this));};Agent['prototype']['handleDrained']=function(){this[_0x94b7('0x9')](!![]);};Agent[_0x94b7('0xc')][_0x94b7('0x7')]=function(_0x56a087){logger[_0x94b7('0xd')](_0x94b7('0xe'),this['squeue']['id'],this[_0x94b7('0x6')]['id']);if(_[_0x94b7('0xf')](this[_0x94b7('0x10')][_0x94b7('0x11')][this['agent']['id']])){logger[_0x94b7('0xd')](_0x94b7('0x12'),this['squeue']['id'],this[_0x94b7('0x6')]['id']);setTimeout(this[_0x94b7('0x13')]['bind'](this),0x3e8);}else{if(this[_0x94b7('0x14')][_0x94b7('0x15')]||util[_0x94b7('0x16')](this[_0x94b7('0x5')]['id'],this[_0x94b7('0x10')][_0x94b7('0x11')][this[_0x94b7('0x6')]['id']],this['squeue']['channel'],![])){this['realtime'][_0x94b7('0x11')][this[_0x94b7('0x6')]['id']][_0x94b7('0x17')]=!![];this[_0x94b7('0x10')][_0x94b7('0x11')][this[_0x94b7('0x6')]['id']]['busyQueue']=undefined;util[_0x94b7('0x18')](this[_0x94b7('0x4')],this[_0x94b7('0x5')]['id'],this[_0x94b7('0x10')][_0x94b7('0x11')][this['agent']['id']],null,this[_0x94b7('0x14')]);util[_0x94b7('0x19')](this[_0x94b7('0x5')]['id'],this[_0x94b7('0x10')][_0x94b7('0x11')][this['agent']['id']],_0x94b7('0x1a')+(this[_0x94b7('0x14')][_0x94b7('0x15')]?_0x94b7('0x1b'):''));}else{logger[_0x94b7('0xd')](_0x94b7('0x1c'),this[_0x94b7('0x5')]['id'],this['agent']['id']);setTimeout(this['push'][_0x94b7('0x8')](this),0x3e8);}}};Agent[_0x94b7('0xc')][_0x94b7('0x9')]=function(_0x2852f6){if(_[_0x94b7('0xf')](this[_0x94b7('0x10')][_0x94b7('0x11')][this[_0x94b7('0x6')]['id']])){return logger[_0x94b7('0xd')](_0x94b7('0x12'),this['squeue']['id'],this[_0x94b7('0x6')]['id']);}else{logger[_0x94b7('0xd')](_0x94b7('0x1d'),this[_0x94b7('0x5')]['id'],this[_0x94b7('0x6')]['id']);util[_0x94b7('0x1e')](this[_0x94b7('0x4')],this[_0x94b7('0x5')]['id'],this[_0x94b7('0x10')]['agents'][this['agent']['id']],null,this[_0x94b7('0x14')]);this[_0x94b7('0x10')][_0x94b7('0x11')][this[_0x94b7('0x6')]['id']][_0x94b7('0x17')]=![];this['realtime'][_0x94b7('0x11')][this['agent']['id']]['busyQueue']=undefined;util[_0x94b7('0x19')](this['squeue']['id'],this[_0x94b7('0x10')]['agents'][this[_0x94b7('0x6')]['id']],_0x2852f6?_0x94b7('0x1f'):'TIMEOUT');}if(!_0x2852f6){setTimeout(this[_0x94b7('0x13')][_0x94b7('0x8')](this),0x3e8);}};function agent(_0x4af654,_0x31a791,_0x3b91ec,_0x3c99b8){return new Agent(_0x4af654,_0x31a791,_0x3b91ec,_0x3c99b8);}module[_0x94b7('0x20')]=agent;