21c317d2a4a59d2703246350f28aea25f5d94a64
[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 _0x278c=['redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','waiting','updateRouting','updateRealtime','mapAgentsId','_rr','map','prototype','loggedIn','paused','length','online','chatPause','available','stringify','format','chat:queue:%s','emit','chat_queue:save','exports','lodash','md5','util','../../../config/environment'];(function(_0x46b9fd,_0x197051){var _0xb0a6e1=function(_0x4b404e){while(--_0x4b404e){_0x46b9fd['push'](_0x46b9fd['shift']());}};_0xb0a6e1(++_0x197051);}(_0x278c,0x1bc));var _0xc278=function(_0x3238ea,_0x91809d){_0x3238ea=_0x3238ea-0x0;var _0x4aaac2=_0x278c[_0x3238ea];return _0x4aaac2;};'use strict';var _=require(_0xc278('0x0'));var md5=require(_0xc278('0x1'));var util=require(_0xc278('0x2'));var Redis=require('ioredis');var config=require(_0xc278('0x3'));config[_0xc278('0x4')]=_[_0xc278('0x5')](config[_0xc278('0x4')],{'host':_0xc278('0x6'),'port':0x18eb});var io=require(_0xc278('0x7'))(new Redis(config[_0xc278('0x4')]));function ChatQueue(_0x81ce40){this['id']=_0x81ce40['id']||0x0;this[_0xc278('0x8')]=_0x81ce40['name']||'';this['timeout']=_0x81ce40[_0xc278('0x9')]||0xa;this[_0xc278('0xa')]=_0x81ce40['strategy']||_0xc278('0xb');this[_0xc278('0xc')]=_0x81ce40[_0xc278('0xc')];this['mapAgentsId']={};this[_0xc278('0xd')]=0x0;this[_0xc278('0x1')]='';this[_0xc278('0xe')]();this[_0xc278('0xf')]();}ChatQueue['prototype'][_0xc278('0xe')]=function(){var _0x35fb93=this[_0xc278('0x10')][_0xc278('0x11')];this['mapAgentsId']=_[_0xc278('0x12')](this['Agents'],'id');this[_0xc278('0x10')][_0xc278('0x11')]=_0x35fb93;};ChatQueue[_0xc278('0x13')]['updateRealtime']=function(){this[_0xc278('0x14')]=0x0;this[_0xc278('0x15')]=0x0;for(var _0x37eaa4=0x0;_0x37eaa4<this[_0xc278('0xc')][_0xc278('0x16')];_0x37eaa4+=0x1){if(this[_0xc278('0xc')][_0x37eaa4][_0xc278('0x17')]){this[_0xc278('0x14')]+=0x1;}if(this[_0xc278('0xc')][_0x37eaa4][_0xc278('0x18')]){this[_0xc278('0x15')]+=0x1;}}this[_0xc278('0x19')]=this[_0xc278('0x14')]-this[_0xc278('0x15')];this[_0xc278('0x19')]=this['available']>=0x0?this[_0xc278('0x19')]:0x0;var _0x484842={'id':this['id'],'available':this['available'],'loggedIn':this[_0xc278('0x14')],'name':this[_0xc278('0x8')],'paused':this[_0xc278('0x15')],'waiting':this[_0xc278('0xd')]};var _0x2f6307=md5(JSON[_0xc278('0x1a')](_0x484842));if(this[_0xc278('0x1')]!==_0x2f6307){this[_0xc278('0x1')]=_0x2f6307;io['to'](util[_0xc278('0x1b')](_0xc278('0x1c'),_0x484842[_0xc278('0x8')]))[_0xc278('0x1d')](_0xc278('0x1e'),_0x484842);}};module[_0xc278('0x1f')]=ChatQueue;