Built motion from commit (unavailable).|2.4.1
[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 _0xbc87=['format','openchannel:queue:%s','emit','openchannel_queue:save','exports','lodash','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRouting','prototype','_rr','map','loggedIn','length','online','paused','available','stringify'];(function(_0x5c9113,_0x217c53){var _0x5e2921=function(_0x10bb73){while(--_0x10bb73){_0x5c9113['push'](_0x5c9113['shift']());}};_0x5e2921(++_0x217c53);}(_0xbc87,0x144));var _0x7bc8=function(_0x35e0ab,_0x5a490b){_0x35e0ab=_0x35e0ab-0x0;var _0x33e87e=_0xbc87[_0x35e0ab];return _0x33e87e;};'use strict';var _=require(_0x7bc8('0x0'));var md5=require('md5');var util=require('util');var Redis=require(_0x7bc8('0x1'));var config=require(_0x7bc8('0x2'));config[_0x7bc8('0x3')]=_['defaults'](config['redis'],{'host':_0x7bc8('0x4'),'port':0x18eb});var io=require(_0x7bc8('0x5'))(new Redis(config[_0x7bc8('0x3')]));function OpenchannelQueue(_0xc8e5a8){this['id']=_0xc8e5a8['id']||0x0;this[_0x7bc8('0x6')]=_0xc8e5a8[_0x7bc8('0x6')]||'';this[_0x7bc8('0x7')]=_0xc8e5a8[_0x7bc8('0x7')]||0xa;this[_0x7bc8('0x8')]=_0xc8e5a8[_0x7bc8('0x8')]||_0x7bc8('0x9');this[_0x7bc8('0xa')]=_0xc8e5a8[_0x7bc8('0xa')];this[_0x7bc8('0xb')]={};this[_0x7bc8('0xc')]=0x0;this[_0x7bc8('0xd')]='';this[_0x7bc8('0xe')]();this['updateRealtime']();}OpenchannelQueue[_0x7bc8('0xf')]['updateRouting']=function(){var _0xc357a2=this[_0x7bc8('0xb')][_0x7bc8('0x10')];this[_0x7bc8('0xb')]=_[_0x7bc8('0x11')](this[_0x7bc8('0xa')],'id');this['mapAgentsId'][_0x7bc8('0x10')]=_0xc357a2;};OpenchannelQueue[_0x7bc8('0xf')]['updateRealtime']=function(){this[_0x7bc8('0x12')]=0x0;this['paused']=0x0;for(var _0x11f135=0x0;_0x11f135<this[_0x7bc8('0xa')][_0x7bc8('0x13')];_0x11f135+=0x1){if(this[_0x7bc8('0xa')][_0x11f135][_0x7bc8('0x14')]){this['loggedIn']+=0x1;}if(this[_0x7bc8('0xa')][_0x11f135]['openchannelPause']){this[_0x7bc8('0x15')]+=0x1;}}this['available']=this[_0x7bc8('0x12')]-this[_0x7bc8('0x15')];this[_0x7bc8('0x16')]=this[_0x7bc8('0x16')]>=0x0?this[_0x7bc8('0x16')]:0x0;var _0xbe1f3a={'id':this['id'],'available':this[_0x7bc8('0x16')],'loggedIn':this['loggedIn'],'name':this['name'],'paused':this[_0x7bc8('0x15')],'waiting':this[_0x7bc8('0xc')]};var _0x67c835=md5(JSON[_0x7bc8('0x17')](_0xbe1f3a));if(this[_0x7bc8('0xd')]!==_0x67c835){this['md5']=_0x67c835;io['to'](util[_0x7bc8('0x18')](_0x7bc8('0x19'),_0xbe1f3a[_0x7bc8('0x6')]))[_0x7bc8('0x1a')](_0x7bc8('0x1b'),_0xbe1f3a);}};module[_0x7bc8('0x1c')]=OpenchannelQueue;