Built motion from commit (unavailable).|2.4.3
[motion2.git] / server / services / routing / model / openchannelQueue.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 _0xbc83=['_rr','prototype','updateRealtime','paused','length','online','loggedIn','openchannelPause','available','stringify','format','emit','openchannel_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','map'];(function(_0x23ae11,_0x7c228c){var _0x1c9700=function(_0x1a95b6){while(--_0x1a95b6){_0x23ae11['push'](_0x23ae11['shift']());}};_0x1c9700(++_0x7c228c);}(_0xbc83,0xa9));var _0x3bc8=function(_0x5006ae,_0x4656c5){_0x5006ae=_0x5006ae-0x0;var _0x24f865=_0xbc83[_0x5006ae];return _0x24f865;};'use strict';var _=require(_0x3bc8('0x0'));var md5=require(_0x3bc8('0x1'));var util=require(_0x3bc8('0x2'));var Redis=require(_0x3bc8('0x3'));var config=require(_0x3bc8('0x4'));config[_0x3bc8('0x5')]=_[_0x3bc8('0x6')](config[_0x3bc8('0x5')],{'host':_0x3bc8('0x7'),'port':0x18eb});var io=require(_0x3bc8('0x8'))(new Redis(config[_0x3bc8('0x5')]));function OpenchannelQueue(_0x2a4b2c){this['id']=_0x2a4b2c['id']||0x0;this[_0x3bc8('0x9')]=_0x2a4b2c[_0x3bc8('0x9')]||'';this[_0x3bc8('0xa')]=_0x2a4b2c['timeout']||0xa;this[_0x3bc8('0xb')]=_0x2a4b2c['strategy']||'beepall';this[_0x3bc8('0xc')]=_0x2a4b2c[_0x3bc8('0xc')];this[_0x3bc8('0xd')]={};this[_0x3bc8('0xe')]=0x0;this['md5']='';this[_0x3bc8('0xf')]();this['updateRealtime']();}OpenchannelQueue['prototype']['updateRouting']=function(){var _0x38cf4f=this[_0x3bc8('0xd')]['_rr'];this['mapAgentsId']=_[_0x3bc8('0x10')](this[_0x3bc8('0xc')],'id');this[_0x3bc8('0xd')][_0x3bc8('0x11')]=_0x38cf4f;};OpenchannelQueue[_0x3bc8('0x12')][_0x3bc8('0x13')]=function(){this['loggedIn']=0x0;this[_0x3bc8('0x14')]=0x0;for(var _0xf3878c=0x0;_0xf3878c<this[_0x3bc8('0xc')][_0x3bc8('0x15')];_0xf3878c+=0x1){if(this[_0x3bc8('0xc')][_0xf3878c][_0x3bc8('0x16')]){this[_0x3bc8('0x17')]+=0x1;}if(this[_0x3bc8('0xc')][_0xf3878c][_0x3bc8('0x18')]){this['paused']+=0x1;}}this[_0x3bc8('0x19')]=this[_0x3bc8('0x17')]-this[_0x3bc8('0x14')];this[_0x3bc8('0x19')]=this['available']>=0x0?this[_0x3bc8('0x19')]:0x0;var _0xa0213f={'id':this['id'],'available':this['available'],'loggedIn':this[_0x3bc8('0x17')],'name':this['name'],'paused':this[_0x3bc8('0x14')],'waiting':this[_0x3bc8('0xe')]};var _0x41ae9c=md5(JSON[_0x3bc8('0x1a')](_0xa0213f));if(this[_0x3bc8('0x1')]!==_0x41ae9c){this[_0x3bc8('0x1')]=_0x41ae9c;io['to'](util[_0x3bc8('0x1b')]('openchannel:queue:%s',_0xa0213f[_0x3bc8('0x9')]))[_0x3bc8('0x1c')](_0x3bc8('0x1d'),_0xa0213f);}};module[_0x3bc8('0x1e')]=OpenchannelQueue;