5463064ae9559ff5603766cc4304bd000ee33801
[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 _0x81f1=['openchannel:queue:%s','emit','openchannel_queue:save','exports','lodash','md5','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','mapAgentsId','waiting','updateRouting','updateRealtime','_rr','loggedIn','length','Agents','online','openchannelPause','paused','available','format'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x81f1,0x108));var _0x181f=function(_0x213402,_0xf97dc0){_0x213402=_0x213402-0x0;var _0x4b7a7d=_0x81f1[_0x213402];return _0x4b7a7d;};'use strict';var _=require(_0x181f('0x0'));var md5=require(_0x181f('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0x181f('0x2'));config['redis']=_['defaults'](config[_0x181f('0x3')],{'host':_0x181f('0x4'),'port':0x18eb});var io=require(_0x181f('0x5'))(new Redis(config['redis']));function OpenchannelQueue(_0x498b54){this['id']=_0x498b54['id']||0x0;this[_0x181f('0x6')]=_0x498b54[_0x181f('0x6')]||'';this['timeout']=_0x498b54[_0x181f('0x7')]||0xa;this[_0x181f('0x8')]=_0x498b54[_0x181f('0x8')]||'beepall';this['Agents']=_0x498b54['Agents'];this[_0x181f('0x9')]={};this[_0x181f('0xa')]=0x0;this[_0x181f('0x1')]='';this[_0x181f('0xb')]();this[_0x181f('0xc')]();}OpenchannelQueue['prototype'][_0x181f('0xb')]=function(){var _0x285ec0=this['mapAgentsId'][_0x181f('0xd')];this[_0x181f('0x9')]=_['map'](this['Agents'],'id');this[_0x181f('0x9')]['_rr']=_0x285ec0;};OpenchannelQueue['prototype'][_0x181f('0xc')]=function(){this[_0x181f('0xe')]=0x0;this['paused']=0x0;for(var _0x301452=0x0;_0x301452<this['Agents'][_0x181f('0xf')];_0x301452+=0x1){if(this[_0x181f('0x10')][_0x301452][_0x181f('0x11')]){this['loggedIn']+=0x1;}if(this['Agents'][_0x301452][_0x181f('0x12')]){this[_0x181f('0x13')]+=0x1;}}this[_0x181f('0x14')]=this[_0x181f('0xe')]-this[_0x181f('0x13')];this[_0x181f('0x14')]=this[_0x181f('0x14')]>=0x0?this['available']:0x0;var _0x39b4a5={'id':this['id'],'available':this[_0x181f('0x14')],'loggedIn':this[_0x181f('0xe')],'name':this[_0x181f('0x6')],'paused':this[_0x181f('0x13')],'waiting':this[_0x181f('0xa')]};var _0x5e3948=md5(JSON['stringify'](_0x39b4a5));if(this[_0x181f('0x1')]!==_0x5e3948){this[_0x181f('0x1')]=_0x5e3948;io['to'](util[_0x181f('0x15')](_0x181f('0x16'),_0x39b4a5[_0x181f('0x6')]))[_0x181f('0x17')](_0x181f('0x18'),_0x39b4a5);}};module[_0x181f('0x19')]=OpenchannelQueue;