32a0e5ec3148aeb21e8313c0bc7ed66a4e09e6e2
[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 _0xbb1b=['timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','mapAgentsId','_rr','map','prototype','loggedIn','length','openchannelPause','paused','available','stringify','format','openchannel:queue:%s','emit','openchannel_queue:save','lodash','md5','util','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name'];(function(_0x597b98,_0x2c312b){var _0x4e49af=function(_0x41c52d){while(--_0x41c52d){_0x597b98['push'](_0x597b98['shift']());}};_0x4e49af(++_0x2c312b);}(_0xbb1b,0x19b));var _0xbbb1=function(_0x304cc7,_0x2a4fd9){_0x304cc7=_0x304cc7-0x0;var _0x22a909=_0xbb1b[_0x304cc7];return _0x22a909;};'use strict';var _=require(_0xbbb1('0x0'));var md5=require(_0xbbb1('0x1'));var util=require(_0xbbb1('0x2'));var Redis=require('ioredis');var config=require(_0xbbb1('0x3'));config['redis']=_[_0xbbb1('0x4')](config[_0xbbb1('0x5')],{'host':_0xbbb1('0x6'),'port':0x18eb});var io=require(_0xbbb1('0x7'))(new Redis(config[_0xbbb1('0x5')]));function OpenchannelQueue(_0x398fcb){this['id']=_0x398fcb['id']||0x0;this[_0xbbb1('0x8')]=_0x398fcb[_0xbbb1('0x8')]||'';this[_0xbbb1('0x9')]=_0x398fcb[_0xbbb1('0x9')]||0xa;this[_0xbbb1('0xa')]=_0x398fcb[_0xbbb1('0xa')]||_0xbbb1('0xb');this[_0xbbb1('0xc')]=_0x398fcb[_0xbbb1('0xc')];this['mapAgentsId']={};this[_0xbbb1('0xd')]=0x0;this['md5']='';this[_0xbbb1('0xe')]();this[_0xbbb1('0xf')]();}OpenchannelQueue['prototype'][_0xbbb1('0xe')]=function(){var _0x1d7250=this[_0xbbb1('0x10')][_0xbbb1('0x11')];this[_0xbbb1('0x10')]=_[_0xbbb1('0x12')](this['Agents'],'id');this[_0xbbb1('0x10')][_0xbbb1('0x11')]=_0x1d7250;};OpenchannelQueue[_0xbbb1('0x13')][_0xbbb1('0xf')]=function(){this[_0xbbb1('0x14')]=0x0;this['paused']=0x0;for(var _0x248c55=0x0;_0x248c55<this[_0xbbb1('0xc')][_0xbbb1('0x15')];_0x248c55+=0x1){if(this[_0xbbb1('0xc')][_0x248c55]['online']){this['loggedIn']+=0x1;}if(this['Agents'][_0x248c55][_0xbbb1('0x16')]){this[_0xbbb1('0x17')]+=0x1;}}this['available']=this[_0xbbb1('0x14')]-this[_0xbbb1('0x17')];this[_0xbbb1('0x18')]=this['available']>=0x0?this[_0xbbb1('0x18')]:0x0;var _0x1fa22c={'id':this['id'],'available':this[_0xbbb1('0x18')],'loggedIn':this[_0xbbb1('0x14')],'name':this[_0xbbb1('0x8')],'paused':this[_0xbbb1('0x17')],'waiting':this[_0xbbb1('0xd')]};var _0x15727f=md5(JSON[_0xbbb1('0x19')](_0x1fa22c));if(this[_0xbbb1('0x1')]!==_0x15727f){this['md5']=_0x15727f;io['to'](util[_0xbbb1('0x1a')](_0xbbb1('0x1b'),_0x1fa22c['name']))[_0xbbb1('0x1c')](_0xbbb1('0x1d'),_0x1fa22c);}};module['exports']=OpenchannelQueue;