Built motion from commit (unavailable).|2.3.93
[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 _0xf530=['chat:queue:%s','emit','chat_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','defaults','localhost','name','timeout','strategy','beepall','Agents','waiting','updateRouting','mapAgentsId','map','_rr','prototype','updateRealtime','paused','length','online','loggedIn','chatPause','available','stringify'];(function(_0x3b517c,_0x533b4e){var _0x5cc760=function(_0x5c9210){while(--_0x5c9210){_0x3b517c['push'](_0x3b517c['shift']());}};_0x5cc760(++_0x533b4e);}(_0xf530,0x18a));var _0x0f53=function(_0x4134c9,_0x59c7a7){_0x4134c9=_0x4134c9-0x0;var _0x2f49b9=_0xf530[_0x4134c9];return _0x2f49b9;};'use strict';var _=require(_0x0f53('0x0'));var md5=require(_0x0f53('0x1'));var util=require(_0x0f53('0x2'));var Redis=require(_0x0f53('0x3'));var config=require(_0x0f53('0x4'));config['redis']=_[_0x0f53('0x5')](config['redis'],{'host':_0x0f53('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function ChatQueue(_0x15b907){this['id']=_0x15b907['id']||0x0;this['name']=_0x15b907[_0x0f53('0x7')]||'';this['timeout']=_0x15b907[_0x0f53('0x8')]||0xa;this[_0x0f53('0x9')]=_0x15b907[_0x0f53('0x9')]||_0x0f53('0xa');this[_0x0f53('0xb')]=_0x15b907[_0x0f53('0xb')];this['mapAgentsId']={};this[_0x0f53('0xc')]=0x0;this[_0x0f53('0x1')]='';this['updateRouting']();this['updateRealtime']();}ChatQueue['prototype'][_0x0f53('0xd')]=function(){var _0x58ffcd=this[_0x0f53('0xe')]['_rr'];this[_0x0f53('0xe')]=_[_0x0f53('0xf')](this[_0x0f53('0xb')],'id');this[_0x0f53('0xe')][_0x0f53('0x10')]=_0x58ffcd;};ChatQueue[_0x0f53('0x11')][_0x0f53('0x12')]=function(){this['loggedIn']=0x0;this[_0x0f53('0x13')]=0x0;for(var _0x14c212=0x0;_0x14c212<this[_0x0f53('0xb')][_0x0f53('0x14')];_0x14c212+=0x1){if(this['Agents'][_0x14c212][_0x0f53('0x15')]){this[_0x0f53('0x16')]+=0x1;}if(this['Agents'][_0x14c212][_0x0f53('0x17')]){this[_0x0f53('0x13')]+=0x1;}}this[_0x0f53('0x18')]=this[_0x0f53('0x16')]-this[_0x0f53('0x13')];this[_0x0f53('0x18')]=this[_0x0f53('0x18')]>=0x0?this[_0x0f53('0x18')]:0x0;var _0x3fabdb={'id':this['id'],'available':this[_0x0f53('0x18')],'loggedIn':this['loggedIn'],'name':this[_0x0f53('0x7')],'paused':this[_0x0f53('0x13')],'waiting':this[_0x0f53('0xc')]};var _0x21ec3b=md5(JSON[_0x0f53('0x19')](_0x3fabdb));if(this[_0x0f53('0x1')]!==_0x21ec3b){this[_0x0f53('0x1')]=_0x21ec3b;io['to'](util['format'](_0x0f53('0x1a'),_0x3fabdb['name']))[_0x0f53('0x1b')](_0x0f53('0x1c'),_0x3fabdb);}};module[_0x0f53('0x1d')]=ChatQueue;