dbcc7b7569ca9f9af09d921a31e789270bf44157
[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 _0x96ab=['emit','openchannel_queue:save','exports','md5','util','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','loggedIn','paused','openchannelPause','available','stringify','format','openchannel:queue:%s'];(function(_0x606704,_0x4a08f8){var _0x11a29d=function(_0x36cae3){while(--_0x36cae3){_0x606704['push'](_0x606704['shift']());}};_0x11a29d(++_0x4a08f8);}(_0x96ab,0xff));var _0xb96a=function(_0xb3c2bd,_0x3559cc){_0xb3c2bd=_0xb3c2bd-0x0;var _0x179415=_0x96ab[_0xb3c2bd];return _0x179415;};'use strict';var _=require('lodash');var md5=require(_0xb96a('0x0'));var util=require(_0xb96a('0x1'));var Redis=require('ioredis');var config=require(_0xb96a('0x2'));config[_0xb96a('0x3')]=_[_0xb96a('0x4')](config[_0xb96a('0x3')],{'host':_0xb96a('0x5'),'port':0x18eb});var io=require(_0xb96a('0x6'))(new Redis(config['redis']));function OpenchannelQueue(_0x3c4fa0){this['id']=_0x3c4fa0['id']||0x0;this[_0xb96a('0x7')]=_0x3c4fa0[_0xb96a('0x7')]||'';this[_0xb96a('0x8')]=_0x3c4fa0[_0xb96a('0x8')]||0xa;this[_0xb96a('0x9')]=_0x3c4fa0[_0xb96a('0x9')]||_0xb96a('0xa');this['Agents']=_0x3c4fa0[_0xb96a('0xb')];this[_0xb96a('0xc')]={};this[_0xb96a('0xd')]=0x0;this[_0xb96a('0x0')]='';this[_0xb96a('0xe')]();this[_0xb96a('0xf')]();}OpenchannelQueue[_0xb96a('0x10')][_0xb96a('0xe')]=function(){var _0x22dc53=this['mapAgentsId'][_0xb96a('0x11')];this[_0xb96a('0xc')]=_['map'](this[_0xb96a('0xb')],'id');this[_0xb96a('0xc')]['_rr']=_0x22dc53;};OpenchannelQueue[_0xb96a('0x10')][_0xb96a('0xf')]=function(){this[_0xb96a('0x12')]=0x0;this[_0xb96a('0x13')]=0x0;for(var _0x2892f6=0x0;_0x2892f6<this[_0xb96a('0xb')]['length'];_0x2892f6+=0x1){if(this[_0xb96a('0xb')][_0x2892f6]['online']){this[_0xb96a('0x12')]+=0x1;}if(this[_0xb96a('0xb')][_0x2892f6][_0xb96a('0x14')]){this['paused']+=0x1;}}this['available']=this[_0xb96a('0x12')]-this[_0xb96a('0x13')];this[_0xb96a('0x15')]=this[_0xb96a('0x15')]>=0x0?this[_0xb96a('0x15')]:0x0;var _0x57a3d4={'id':this['id'],'available':this[_0xb96a('0x15')],'loggedIn':this[_0xb96a('0x12')],'name':this[_0xb96a('0x7')],'paused':this[_0xb96a('0x13')],'waiting':this[_0xb96a('0xd')]};var _0x3c1aa8=md5(JSON[_0xb96a('0x16')](_0x57a3d4));if(this[_0xb96a('0x0')]!==_0x3c1aa8){this[_0xb96a('0x0')]=_0x3c1aa8;io['to'](util[_0xb96a('0x17')](_0xb96a('0x18'),_0x57a3d4[_0xb96a('0x7')]))[_0xb96a('0x19')](_0xb96a('0x1a'),_0x57a3d4);}};module[_0xb96a('0x1b')]=OpenchannelQueue;