Built motion from commit (unavailable).|2.5.30
[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 _0x9d64=['md5','updateRouting','updateRealtime','prototype','_rr','map','loggedIn','length','openchannelPause','paused','available','waiting','format','openchannel:queue:%s','openchannel_queue:save','exports','lodash','util','ioredis','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId'];(function(_0x11163b,_0x33dc6e){var _0x3fb453=function(_0x298260){while(--_0x298260){_0x11163b['push'](_0x11163b['shift']());}};_0x3fb453(++_0x33dc6e);}(_0x9d64,0xdb));var _0x49d6=function(_0x17ec0a,_0x373ebc){_0x17ec0a=_0x17ec0a-0x0;var _0x58c862=_0x9d64[_0x17ec0a];return _0x58c862;};'use strict';var _=require(_0x49d6('0x0'));var md5=require('md5');var util=require(_0x49d6('0x1'));var Redis=require(_0x49d6('0x2'));var config=require('../../../config/environment');config[_0x49d6('0x3')]=_[_0x49d6('0x4')](config[_0x49d6('0x3')],{'host':_0x49d6('0x5'),'port':0x18eb});var io=require(_0x49d6('0x6'))(new Redis(config[_0x49d6('0x3')]));function OpenchannelQueue(_0x5bed25){this['id']=_0x5bed25['id']||0x0;this[_0x49d6('0x7')]=_0x5bed25[_0x49d6('0x7')]||'';this[_0x49d6('0x8')]=_0x5bed25[_0x49d6('0x8')]||0xa;this['strategy']=_0x5bed25[_0x49d6('0x9')]||_0x49d6('0xa');this['Agents']=_0x5bed25[_0x49d6('0xb')];this[_0x49d6('0xc')]={};this['waiting']=0x0;this[_0x49d6('0xd')]='';this[_0x49d6('0xe')]();this[_0x49d6('0xf')]();}OpenchannelQueue[_0x49d6('0x10')][_0x49d6('0xe')]=function(){var _0x47dd7e=this[_0x49d6('0xc')][_0x49d6('0x11')];this[_0x49d6('0xc')]=_[_0x49d6('0x12')](this['Agents'],'id');this[_0x49d6('0xc')]['_rr']=_0x47dd7e;};OpenchannelQueue[_0x49d6('0x10')][_0x49d6('0xf')]=function(){this[_0x49d6('0x13')]=0x0;this['paused']=0x0;for(var _0x1dbcb6=0x0;_0x1dbcb6<this['Agents'][_0x49d6('0x14')];_0x1dbcb6+=0x1){if(this[_0x49d6('0xb')][_0x1dbcb6]['online']){this[_0x49d6('0x13')]+=0x1;}if(this[_0x49d6('0xb')][_0x1dbcb6][_0x49d6('0x15')]){this[_0x49d6('0x16')]+=0x1;}}this[_0x49d6('0x17')]=this['loggedIn']-this['paused'];this[_0x49d6('0x17')]=this[_0x49d6('0x17')]>=0x0?this[_0x49d6('0x17')]:0x0;var _0x496cf9={'id':this['id'],'available':this[_0x49d6('0x17')],'loggedIn':this[_0x49d6('0x13')],'name':this['name'],'paused':this[_0x49d6('0x16')],'waiting':this[_0x49d6('0x18')]};var _0x5e8123=md5(JSON['stringify'](_0x496cf9));if(this[_0x49d6('0xd')]!==_0x5e8123){this['md5']=_0x5e8123;io['to'](util[_0x49d6('0x19')](_0x49d6('0x1a'),_0x496cf9[_0x49d6('0x7')]))['emit'](_0x49d6('0x1b'),_0x496cf9);}};module[_0x49d6('0x1c')]=OpenchannelQueue;