9871960b19837aa2f3c35c0bd3c076084709273d
[motion2.git] / server / services / routing / model / chatQueue.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 _0xe303=['_rr','paused','length','online','loggedIn','chatPause','available','stringify','format','chat:queue:%s','chat_queue:save','md5','ioredis','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','map'];(function(_0x101154,_0x1e7615){var _0x59e025=function(_0x5a0f31){while(--_0x5a0f31){_0x101154['push'](_0x101154['shift']());}};_0x59e025(++_0x1e7615);}(_0xe303,0xc8));var _0x3e30=function(_0x3b32ed,_0x47e199){_0x3b32ed=_0x3b32ed-0x0;var _0x19fccc=_0xe303[_0x3b32ed];return _0x19fccc;};'use strict';var _=require('lodash');var md5=require(_0x3e30('0x0'));var util=require('util');var Redis=require(_0x3e30('0x1'));var config=require(_0x3e30('0x2'));config[_0x3e30('0x3')]=_['defaults'](config['redis'],{'host':_0x3e30('0x4'),'port':0x18eb});var io=require(_0x3e30('0x5'))(new Redis(config[_0x3e30('0x3')]));function ChatQueue(_0x5e3b7c){this['id']=_0x5e3b7c['id']||0x0;this[_0x3e30('0x6')]=_0x5e3b7c['name']||'';this[_0x3e30('0x7')]=_0x5e3b7c[_0x3e30('0x7')]||0xa;this[_0x3e30('0x8')]=_0x5e3b7c[_0x3e30('0x8')]||_0x3e30('0x9');this[_0x3e30('0xa')]=_0x5e3b7c['Agents'];this[_0x3e30('0xb')]={};this[_0x3e30('0xc')]=0x0;this[_0x3e30('0x0')]='';this[_0x3e30('0xd')]();this['updateRealtime']();}ChatQueue[_0x3e30('0xe')][_0x3e30('0xd')]=function(){var _0xd9923c=this[_0x3e30('0xb')]['_rr'];this[_0x3e30('0xb')]=_[_0x3e30('0xf')](this['Agents'],'id');this[_0x3e30('0xb')][_0x3e30('0x10')]=_0xd9923c;};ChatQueue[_0x3e30('0xe')]['updateRealtime']=function(){this['loggedIn']=0x0;this[_0x3e30('0x11')]=0x0;for(var _0xdebf14=0x0;_0xdebf14<this[_0x3e30('0xa')][_0x3e30('0x12')];_0xdebf14+=0x1){if(this[_0x3e30('0xa')][_0xdebf14][_0x3e30('0x13')]){this[_0x3e30('0x14')]+=0x1;}if(this[_0x3e30('0xa')][_0xdebf14][_0x3e30('0x15')]){this[_0x3e30('0x11')]+=0x1;}}this['available']=this['loggedIn']-this[_0x3e30('0x11')];this[_0x3e30('0x16')]=this[_0x3e30('0x16')]>=0x0?this[_0x3e30('0x16')]:0x0;var _0x4e9439={'id':this['id'],'available':this[_0x3e30('0x16')],'loggedIn':this[_0x3e30('0x14')],'name':this['name'],'paused':this['paused'],'waiting':this[_0x3e30('0xc')]};var _0x337f4c=md5(JSON[_0x3e30('0x17')](_0x4e9439));if(this[_0x3e30('0x0')]!==_0x337f4c){this[_0x3e30('0x0')]=_0x337f4c;io['to'](util[_0x3e30('0x18')](_0x3e30('0x19'),_0x4e9439['name']))['emit'](_0x3e30('0x1a'),_0x4e9439);}};module['exports']=ChatQueue;