Built motion from commit (unavailable).|2.5.2
[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 _0x2524=['beepall','Agents','updateRouting','_rr','map','prototype','updateRealtime','loggedIn','paused','length','online','available','waiting','format','chat:queue:%s','emit','chat_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','socket.io-emitter','name','timeout','strategy'];(function(_0x35f502,_0x6b2366){var _0x5c40f5=function(_0x150ce9){while(--_0x150ce9){_0x35f502['push'](_0x35f502['shift']());}};_0x5c40f5(++_0x6b2366);}(_0x2524,0x86));var _0x4252=function(_0x557d4e,_0x2069c0){_0x557d4e=_0x557d4e-0x0;var _0x2b182d=_0x2524[_0x557d4e];return _0x2b182d;};'use strict';var _=require(_0x4252('0x0'));var md5=require(_0x4252('0x1'));var util=require(_0x4252('0x2'));var Redis=require(_0x4252('0x3'));var config=require(_0x4252('0x4'));config[_0x4252('0x5')]=_[_0x4252('0x6')](config[_0x4252('0x5')],{'host':'localhost','port':0x18eb});var io=require(_0x4252('0x7'))(new Redis(config[_0x4252('0x5')]));function ChatQueue(_0x37ec4c){this['id']=_0x37ec4c['id']||0x0;this[_0x4252('0x8')]=_0x37ec4c[_0x4252('0x8')]||'';this[_0x4252('0x9')]=_0x37ec4c['timeout']||0xa;this[_0x4252('0xa')]=_0x37ec4c[_0x4252('0xa')]||_0x4252('0xb');this['Agents']=_0x37ec4c[_0x4252('0xc')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x4252('0x1')]='';this[_0x4252('0xd')]();this['updateRealtime']();}ChatQueue['prototype']['updateRouting']=function(){var _0x32e723=this['mapAgentsId'][_0x4252('0xe')];this['mapAgentsId']=_[_0x4252('0xf')](this['Agents'],'id');this['mapAgentsId']['_rr']=_0x32e723;};ChatQueue[_0x4252('0x10')][_0x4252('0x11')]=function(){this[_0x4252('0x12')]=0x0;this[_0x4252('0x13')]=0x0;for(var _0x5e95a1=0x0;_0x5e95a1<this[_0x4252('0xc')][_0x4252('0x14')];_0x5e95a1+=0x1){if(this[_0x4252('0xc')][_0x5e95a1][_0x4252('0x15')]){this['loggedIn']+=0x1;}if(this[_0x4252('0xc')][_0x5e95a1]['chatPause']){this[_0x4252('0x13')]+=0x1;}}this[_0x4252('0x16')]=this[_0x4252('0x12')]-this[_0x4252('0x13')];this['available']=this[_0x4252('0x16')]>=0x0?this['available']:0x0;var _0x4d96dd={'id':this['id'],'available':this[_0x4252('0x16')],'loggedIn':this[_0x4252('0x12')],'name':this[_0x4252('0x8')],'paused':this[_0x4252('0x13')],'waiting':this[_0x4252('0x17')]};var _0x48cb4a=md5(JSON['stringify'](_0x4d96dd));if(this[_0x4252('0x1')]!==_0x48cb4a){this[_0x4252('0x1')]=_0x48cb4a;io['to'](util[_0x4252('0x18')](_0x4252('0x19'),_0x4d96dd['name']))[_0x4252('0x1a')](_0x4252('0x1b'),_0x4d96dd);}};module[_0x4252('0x1c')]=ChatQueue;