706bf03ddfe3e634d0fde244bdbfb1c0d7726625
[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 _0x9594=['_rr','map','paused','online','loggedIn','chatPause','available','stringify','format','chat:queue:%s','emit','chat_queue:save','lodash','md5','util','ioredis','../../../config/environment','redis','localhost','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype'];(function(_0x4848dd,_0x437833){var _0x3eaef0=function(_0x2175a4){while(--_0x2175a4){_0x4848dd['push'](_0x4848dd['shift']());}};_0x3eaef0(++_0x437833);}(_0x9594,0x140));var _0x4959=function(_0x3ce3c,_0x319337){_0x3ce3c=_0x3ce3c-0x0;var _0x55a2c9=_0x9594[_0x3ce3c];return _0x55a2c9;};'use strict';var _=require(_0x4959('0x0'));var md5=require(_0x4959('0x1'));var util=require(_0x4959('0x2'));var Redis=require(_0x4959('0x3'));var config=require(_0x4959('0x4'));config[_0x4959('0x5')]=_['defaults'](config[_0x4959('0x5')],{'host':_0x4959('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x4959('0x5')]));function ChatQueue(_0x3f6ca0){this['id']=_0x3f6ca0['id']||0x0;this['name']=_0x3f6ca0[_0x4959('0x7')]||'';this['timeout']=_0x3f6ca0[_0x4959('0x8')]||0xa;this[_0x4959('0x9')]=_0x3f6ca0[_0x4959('0x9')]||_0x4959('0xa');this[_0x4959('0xb')]=_0x3f6ca0[_0x4959('0xb')];this[_0x4959('0xc')]={};this[_0x4959('0xd')]=0x0;this[_0x4959('0x1')]='';this[_0x4959('0xe')]();this['updateRealtime']();}ChatQueue[_0x4959('0xf')][_0x4959('0xe')]=function(){var _0x5f5585=this['mapAgentsId'][_0x4959('0x10')];this[_0x4959('0xc')]=_[_0x4959('0x11')](this[_0x4959('0xb')],'id');this[_0x4959('0xc')][_0x4959('0x10')]=_0x5f5585;};ChatQueue[_0x4959('0xf')]['updateRealtime']=function(){this['loggedIn']=0x0;this[_0x4959('0x12')]=0x0;for(var _0x414de1=0x0;_0x414de1<this[_0x4959('0xb')]['length'];_0x414de1+=0x1){if(this['Agents'][_0x414de1][_0x4959('0x13')]){this[_0x4959('0x14')]+=0x1;}if(this[_0x4959('0xb')][_0x414de1][_0x4959('0x15')]){this[_0x4959('0x12')]+=0x1;}}this[_0x4959('0x16')]=this[_0x4959('0x14')]-this['paused'];this[_0x4959('0x16')]=this['available']>=0x0?this[_0x4959('0x16')]:0x0;var _0x197adb={'id':this['id'],'available':this[_0x4959('0x16')],'loggedIn':this[_0x4959('0x14')],'name':this[_0x4959('0x7')],'paused':this[_0x4959('0x12')],'waiting':this[_0x4959('0xd')]};var _0x2c1497=md5(JSON[_0x4959('0x17')](_0x197adb));if(this[_0x4959('0x1')]!==_0x2c1497){this[_0x4959('0x1')]=_0x2c1497;io['to'](util[_0x4959('0x18')](_0x4959('0x19'),_0x197adb['name']))[_0x4959('0x1a')](_0x4959('0x1b'),_0x197adb);}};module['exports']=ChatQueue;