ee642e63158661b196b9ffa1c835c3db424d3a65
[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 _0x5a7f=['online','available','format','chat:queue:%s','emit','chat_queue:save','lodash','md5','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','map','updateRealtime','loggedIn','paused','length'];(function(_0x3ff8b4,_0x14030b){var _0x320511=function(_0x507c75){while(--_0x507c75){_0x3ff8b4['push'](_0x3ff8b4['shift']());}};_0x320511(++_0x14030b);}(_0x5a7f,0x19e));var _0xf5a7=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x5a7f[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xf5a7('0x0'));var md5=require(_0xf5a7('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0xf5a7('0x2'));config[_0xf5a7('0x3')]=_['defaults'](config['redis'],{'host':_0xf5a7('0x4'),'port':0x18eb});var io=require(_0xf5a7('0x5'))(new Redis(config['redis']));function ChatQueue(_0x1c5b07){this['id']=_0x1c5b07['id']||0x0;this[_0xf5a7('0x6')]=_0x1c5b07[_0xf5a7('0x6')]||'';this['timeout']=_0x1c5b07[_0xf5a7('0x7')]||0xa;this[_0xf5a7('0x8')]=_0x1c5b07[_0xf5a7('0x8')]||'beepall';this[_0xf5a7('0x9')]=_0x1c5b07['Agents'];this[_0xf5a7('0xa')]={};this[_0xf5a7('0xb')]=0x0;this['md5']='';this['updateRouting']();this['updateRealtime']();}ChatQueue['prototype'][_0xf5a7('0xc')]=function(){var _0x2bd18f=this[_0xf5a7('0xa')]['_rr'];this[_0xf5a7('0xa')]=_[_0xf5a7('0xd')](this[_0xf5a7('0x9')],'id');this[_0xf5a7('0xa')]['_rr']=_0x2bd18f;};ChatQueue['prototype'][_0xf5a7('0xe')]=function(){this[_0xf5a7('0xf')]=0x0;this[_0xf5a7('0x10')]=0x0;for(var _0x3dff7e=0x0;_0x3dff7e<this[_0xf5a7('0x9')][_0xf5a7('0x11')];_0x3dff7e+=0x1){if(this[_0xf5a7('0x9')][_0x3dff7e][_0xf5a7('0x12')]){this[_0xf5a7('0xf')]+=0x1;}if(this[_0xf5a7('0x9')][_0x3dff7e]['chatPause']){this[_0xf5a7('0x10')]+=0x1;}}this[_0xf5a7('0x13')]=this['loggedIn']-this[_0xf5a7('0x10')];this[_0xf5a7('0x13')]=this[_0xf5a7('0x13')]>=0x0?this[_0xf5a7('0x13')]:0x0;var _0x3e30af={'id':this['id'],'available':this[_0xf5a7('0x13')],'loggedIn':this[_0xf5a7('0xf')],'name':this[_0xf5a7('0x6')],'paused':this[_0xf5a7('0x10')],'waiting':this[_0xf5a7('0xb')]};var _0x106d3c=md5(JSON['stringify'](_0x3e30af));if(this[_0xf5a7('0x1')]!==_0x106d3c){this[_0xf5a7('0x1')]=_0x106d3c;io['to'](util[_0xf5a7('0x14')](_0xf5a7('0x15'),_0x3e30af[_0xf5a7('0x6')]))[_0xf5a7('0x16')](_0xf5a7('0x17'),_0x3e30af);}};module['exports']=ChatQueue;