Built motion from commit (unavailable).|2.5.15
[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 _0x8251=['socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRealtime','updateRouting','map','_rr','prototype','loggedIn','length','online','openchannelPause','paused','available','openchannel:queue:%s','openchannel_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults'];(function(_0x31d4d2,_0x44e8cc){var _0x2dee0b=function(_0x3c267a){while(--_0x3c267a){_0x31d4d2['push'](_0x31d4d2['shift']());}};_0x2dee0b(++_0x44e8cc);}(_0x8251,0xf5));var _0x1825=function(_0x199572,_0x33e667){_0x199572=_0x199572-0x0;var _0x13cfa3=_0x8251[_0x199572];return _0x13cfa3;};'use strict';var _=require(_0x1825('0x0'));var md5=require(_0x1825('0x1'));var util=require(_0x1825('0x2'));var Redis=require(_0x1825('0x3'));var config=require(_0x1825('0x4'));config[_0x1825('0x5')]=_[_0x1825('0x6')](config[_0x1825('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x1825('0x7'))(new Redis(config[_0x1825('0x5')]));function OpenchannelQueue(_0x211506){this['id']=_0x211506['id']||0x0;this[_0x1825('0x8')]=_0x211506['name']||'';this[_0x1825('0x9')]=_0x211506['timeout']||0xa;this[_0x1825('0xa')]=_0x211506['strategy']||'beepall';this[_0x1825('0xb')]=_0x211506['Agents'];this[_0x1825('0xc')]={};this[_0x1825('0xd')]=0x0;this['md5']='';this['updateRouting']();this[_0x1825('0xe')]();}OpenchannelQueue['prototype'][_0x1825('0xf')]=function(){var _0x774db3=this[_0x1825('0xc')]['_rr'];this[_0x1825('0xc')]=_[_0x1825('0x10')](this[_0x1825('0xb')],'id');this[_0x1825('0xc')][_0x1825('0x11')]=_0x774db3;};OpenchannelQueue[_0x1825('0x12')][_0x1825('0xe')]=function(){this[_0x1825('0x13')]=0x0;this['paused']=0x0;for(var _0x2146f4=0x0;_0x2146f4<this[_0x1825('0xb')][_0x1825('0x14')];_0x2146f4+=0x1){if(this['Agents'][_0x2146f4][_0x1825('0x15')]){this[_0x1825('0x13')]+=0x1;}if(this[_0x1825('0xb')][_0x2146f4][_0x1825('0x16')]){this[_0x1825('0x17')]+=0x1;}}this[_0x1825('0x18')]=this['loggedIn']-this['paused'];this[_0x1825('0x18')]=this[_0x1825('0x18')]>=0x0?this[_0x1825('0x18')]:0x0;var _0x25921b={'id':this['id'],'available':this['available'],'loggedIn':this['loggedIn'],'name':this[_0x1825('0x8')],'paused':this[_0x1825('0x17')],'waiting':this['waiting']};var _0x46e3e0=md5(JSON['stringify'](_0x25921b));if(this['md5']!==_0x46e3e0){this[_0x1825('0x1')]=_0x46e3e0;io['to'](util['format'](_0x1825('0x19'),_0x25921b[_0x1825('0x8')]))['emit'](_0x1825('0x1a'),_0x25921b);}};module[_0x1825('0x1b')]=OpenchannelQueue;