d47665a261e998b829fcea3ce07f7410a65c0b02
[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 _0xbb55=['loggedIn','paused','online','chatPause','available','stringify','md5','format','chat:queue:%s','chat_queue:save','exports','lodash','util','ioredis','../../../config/environment','defaults','redis','localhost','socket.io-emitter','name','timeout','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr','map'];(function(_0x5d24da,_0x150462){var _0x19782d=function(_0x15cc0f){while(--_0x15cc0f){_0x5d24da['push'](_0x5d24da['shift']());}};_0x19782d(++_0x150462);}(_0xbb55,0xb9));var _0x5bb5=function(_0x96f4ca,_0xdbc7cc){_0x96f4ca=_0x96f4ca-0x0;var _0x3c94f9=_0xbb55[_0x96f4ca];return _0x3c94f9;};'use strict';var _=require(_0x5bb5('0x0'));var md5=require('md5');var util=require(_0x5bb5('0x1'));var Redis=require(_0x5bb5('0x2'));var config=require(_0x5bb5('0x3'));config['redis']=_[_0x5bb5('0x4')](config[_0x5bb5('0x5')],{'host':_0x5bb5('0x6'),'port':0x18eb});var io=require(_0x5bb5('0x7'))(new Redis(config['redis']));function ChatQueue(_0x4af11d){this['id']=_0x4af11d['id']||0x0;this[_0x5bb5('0x8')]=_0x4af11d[_0x5bb5('0x8')]||'';this[_0x5bb5('0x9')]=_0x4af11d[_0x5bb5('0x9')]||0xa;this['strategy']=_0x4af11d['strategy']||'beepall';this[_0x5bb5('0xa')]=_0x4af11d['Agents'];this[_0x5bb5('0xb')]={};this[_0x5bb5('0xc')]=0x0;this['md5']='';this[_0x5bb5('0xd')]();this[_0x5bb5('0xe')]();}ChatQueue[_0x5bb5('0xf')][_0x5bb5('0xd')]=function(){var _0x9faa3b=this[_0x5bb5('0xb')][_0x5bb5('0x10')];this[_0x5bb5('0xb')]=_[_0x5bb5('0x11')](this[_0x5bb5('0xa')],'id');this['mapAgentsId'][_0x5bb5('0x10')]=_0x9faa3b;};ChatQueue[_0x5bb5('0xf')]['updateRealtime']=function(){this[_0x5bb5('0x12')]=0x0;this[_0x5bb5('0x13')]=0x0;for(var _0x1cb399=0x0;_0x1cb399<this[_0x5bb5('0xa')]['length'];_0x1cb399+=0x1){if(this[_0x5bb5('0xa')][_0x1cb399][_0x5bb5('0x14')]){this['loggedIn']+=0x1;}if(this[_0x5bb5('0xa')][_0x1cb399][_0x5bb5('0x15')]){this[_0x5bb5('0x13')]+=0x1;}}this[_0x5bb5('0x16')]=this[_0x5bb5('0x12')]-this['paused'];this[_0x5bb5('0x16')]=this[_0x5bb5('0x16')]>=0x0?this[_0x5bb5('0x16')]:0x0;var _0x372b5e={'id':this['id'],'available':this[_0x5bb5('0x16')],'loggedIn':this['loggedIn'],'name':this[_0x5bb5('0x8')],'paused':this[_0x5bb5('0x13')],'waiting':this[_0x5bb5('0xc')]};var _0x374ed8=md5(JSON[_0x5bb5('0x17')](_0x372b5e));if(this[_0x5bb5('0x18')]!==_0x374ed8){this['md5']=_0x374ed8;io['to'](util[_0x5bb5('0x19')](_0x5bb5('0x1a'),_0x372b5e[_0x5bb5('0x8')]))['emit'](_0x5bb5('0x1b'),_0x372b5e);}};module[_0x5bb5('0x1c')]=ChatQueue;