0e8f477cbeeec5cafa486d3308bea4be1970681b
[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 _0x359d=['mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map','Agents','length','online','loggedIn','openchannelPause','paused','available','format','openchannel:queue:%s','emit','openchannel_queue:save','exports','md5','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout'];(function(_0x497971,_0x4a7f7d){var _0xefaa97=function(_0xec8984){while(--_0xec8984){_0x497971['push'](_0x497971['shift']());}};_0xefaa97(++_0x4a7f7d);}(_0x359d,0xeb));var _0xd359=function(_0x1e4a8e,_0x18022b){_0x1e4a8e=_0x1e4a8e-0x0;var _0x5408f9=_0x359d[_0x1e4a8e];return _0x5408f9;};'use strict';var _=require('lodash');var md5=require(_0xd359('0x0'));var util=require('util');var Redis=require(_0xd359('0x1'));var config=require(_0xd359('0x2'));config[_0xd359('0x3')]=_[_0xd359('0x4')](config[_0xd359('0x3')],{'host':_0xd359('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function OpenchannelQueue(_0x17acdb){this['id']=_0x17acdb['id']||0x0;this[_0xd359('0x6')]=_0x17acdb[_0xd359('0x6')]||'';this['timeout']=_0x17acdb[_0xd359('0x7')]||0xa;this['strategy']=_0x17acdb['strategy']||'beepall';this['Agents']=_0x17acdb['Agents'];this[_0xd359('0x8')]={};this[_0xd359('0x9')]=0x0;this[_0xd359('0x0')]='';this[_0xd359('0xa')]();this[_0xd359('0xb')]();}OpenchannelQueue[_0xd359('0xc')]['updateRouting']=function(){var _0x1b098a=this[_0xd359('0x8')][_0xd359('0xd')];this[_0xd359('0x8')]=_[_0xd359('0xe')](this[_0xd359('0xf')],'id');this[_0xd359('0x8')][_0xd359('0xd')]=_0x1b098a;};OpenchannelQueue[_0xd359('0xc')][_0xd359('0xb')]=function(){this['loggedIn']=0x0;this['paused']=0x0;for(var _0x15f6d0=0x0;_0x15f6d0<this[_0xd359('0xf')][_0xd359('0x10')];_0x15f6d0+=0x1){if(this[_0xd359('0xf')][_0x15f6d0][_0xd359('0x11')]){this[_0xd359('0x12')]+=0x1;}if(this['Agents'][_0x15f6d0][_0xd359('0x13')]){this[_0xd359('0x14')]+=0x1;}}this[_0xd359('0x15')]=this[_0xd359('0x12')]-this[_0xd359('0x14')];this['available']=this[_0xd359('0x15')]>=0x0?this[_0xd359('0x15')]:0x0;var _0x2215e5={'id':this['id'],'available':this[_0xd359('0x15')],'loggedIn':this[_0xd359('0x12')],'name':this[_0xd359('0x6')],'paused':this[_0xd359('0x14')],'waiting':this[_0xd359('0x9')]};var _0x2d3448=md5(JSON['stringify'](_0x2215e5));if(this[_0xd359('0x0')]!==_0x2d3448){this[_0xd359('0x0')]=_0x2d3448;io['to'](util[_0xd359('0x16')](_0xd359('0x17'),_0x2215e5[_0xd359('0x6')]))[_0xd359('0x18')](_0xd359('0x19'),_0x2215e5);}};module[_0xd359('0x1a')]=OpenchannelQueue;