Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / services / routing / model / openchannelQueue.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 _0xd577=['emit','openchannel_queue:save','exports','lodash','md5','../../../config/environment','defaults','redis','name','timeout','strategy','beepall','Agents','mapAgentsId','updateRouting','updateRealtime','prototype','map','_rr','loggedIn','paused','length','online','openchannelPause','available','waiting','format','openchannel:queue:%s'];(function(_0x5c6311,_0x26cba3){var _0x2dcf7a=function(_0x1746db){while(--_0x1746db){_0x5c6311['push'](_0x5c6311['shift']());}};_0x2dcf7a(++_0x26cba3);}(_0xd577,0x18b));var _0x7d57=function(_0x438912,_0x3f7f74){_0x438912=_0x438912-0x0;var _0x18112f=_0xd577[_0x438912];return _0x18112f;};'use strict';var _=require(_0x7d57('0x0'));var md5=require(_0x7d57('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0x7d57('0x2'));config['redis']=_[_0x7d57('0x3')](config[_0x7d57('0x4')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function OpenchannelQueue(_0x5e29c9){this['id']=_0x5e29c9['id']||0x0;this['name']=_0x5e29c9[_0x7d57('0x5')]||'';this[_0x7d57('0x6')]=_0x5e29c9[_0x7d57('0x6')]||0xa;this[_0x7d57('0x7')]=_0x5e29c9[_0x7d57('0x7')]||_0x7d57('0x8');this[_0x7d57('0x9')]=_0x5e29c9[_0x7d57('0x9')];this[_0x7d57('0xa')]={};this['waiting']=0x0;this[_0x7d57('0x1')]='';this[_0x7d57('0xb')]();this[_0x7d57('0xc')]();}OpenchannelQueue[_0x7d57('0xd')]['updateRouting']=function(){var _0x285e92=this['mapAgentsId']['_rr'];this[_0x7d57('0xa')]=_[_0x7d57('0xe')](this[_0x7d57('0x9')],'id');this[_0x7d57('0xa')][_0x7d57('0xf')]=_0x285e92;};OpenchannelQueue['prototype'][_0x7d57('0xc')]=function(){this[_0x7d57('0x10')]=0x0;this[_0x7d57('0x11')]=0x0;for(var _0x172fac=0x0;_0x172fac<this[_0x7d57('0x9')][_0x7d57('0x12')];_0x172fac+=0x1){if(this[_0x7d57('0x9')][_0x172fac][_0x7d57('0x13')]){this[_0x7d57('0x10')]+=0x1;}if(this[_0x7d57('0x9')][_0x172fac][_0x7d57('0x14')]){this[_0x7d57('0x11')]+=0x1;}}this[_0x7d57('0x15')]=this['loggedIn']-this[_0x7d57('0x11')];this[_0x7d57('0x15')]=this['available']>=0x0?this[_0x7d57('0x15')]:0x0;var _0x59db68={'id':this['id'],'available':this[_0x7d57('0x15')],'loggedIn':this[_0x7d57('0x10')],'name':this[_0x7d57('0x5')],'paused':this[_0x7d57('0x11')],'waiting':this[_0x7d57('0x16')]};var _0xcabe8=md5(JSON['stringify'](_0x59db68));if(this['md5']!==_0xcabe8){this[_0x7d57('0x1')]=_0xcabe8;io['to'](util[_0x7d57('0x17')](_0x7d57('0x18'),_0x59db68[_0x7d57('0x5')]))[_0x7d57('0x19')](_0x7d57('0x1a'),_0x59db68);}};module[_0x7d57('0x1b')]=OpenchannelQueue;