Built motion from commit (unavailable).|2.5.0
[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 _0x8fc1=['updateRealtime','_rr','map','prototype','paused','length','online','openchannelPause','available','loggedIn','stringify','format','openchannel:queue:%s','emit','openchannel_queue:save','lodash','md5','../../../config/environment','redis','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting'];(function(_0x288cf4,_0x2dad12){var _0x38f2d1=function(_0x1d53bd){while(--_0x1d53bd){_0x288cf4['push'](_0x288cf4['shift']());}};_0x38f2d1(++_0x2dad12);}(_0x8fc1,0xef));var _0x18fc=function(_0x3160fd,_0x1249f1){_0x3160fd=_0x3160fd-0x0;var _0x381ffe=_0x8fc1[_0x3160fd];return _0x381ffe;};'use strict';var _=require(_0x18fc('0x0'));var md5=require(_0x18fc('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0x18fc('0x2'));config[_0x18fc('0x3')]=_['defaults'](config[_0x18fc('0x3')],{'host':_0x18fc('0x4'),'port':0x18eb});var io=require(_0x18fc('0x5'))(new Redis(config[_0x18fc('0x3')]));function OpenchannelQueue(_0x32bd09){this['id']=_0x32bd09['id']||0x0;this[_0x18fc('0x6')]=_0x32bd09['name']||'';this[_0x18fc('0x7')]=_0x32bd09[_0x18fc('0x7')]||0xa;this[_0x18fc('0x8')]=_0x32bd09[_0x18fc('0x8')]||_0x18fc('0x9');this['Agents']=_0x32bd09[_0x18fc('0xa')];this[_0x18fc('0xb')]={};this[_0x18fc('0xc')]=0x0;this[_0x18fc('0x1')]='';this['updateRouting']();this[_0x18fc('0xd')]();}OpenchannelQueue['prototype']['updateRouting']=function(){var _0x8bafef=this[_0x18fc('0xb')][_0x18fc('0xe')];this[_0x18fc('0xb')]=_[_0x18fc('0xf')](this[_0x18fc('0xa')],'id');this[_0x18fc('0xb')][_0x18fc('0xe')]=_0x8bafef;};OpenchannelQueue[_0x18fc('0x10')][_0x18fc('0xd')]=function(){this['loggedIn']=0x0;this[_0x18fc('0x11')]=0x0;for(var _0x4548ba=0x0;_0x4548ba<this['Agents'][_0x18fc('0x12')];_0x4548ba+=0x1){if(this[_0x18fc('0xa')][_0x4548ba][_0x18fc('0x13')]){this['loggedIn']+=0x1;}if(this[_0x18fc('0xa')][_0x4548ba][_0x18fc('0x14')]){this[_0x18fc('0x11')]+=0x1;}}this[_0x18fc('0x15')]=this[_0x18fc('0x16')]-this[_0x18fc('0x11')];this[_0x18fc('0x15')]=this[_0x18fc('0x15')]>=0x0?this[_0x18fc('0x15')]:0x0;var _0x442415={'id':this['id'],'available':this[_0x18fc('0x15')],'loggedIn':this[_0x18fc('0x16')],'name':this[_0x18fc('0x6')],'paused':this[_0x18fc('0x11')],'waiting':this[_0x18fc('0xc')]};var _0xc30a2a=md5(JSON[_0x18fc('0x17')](_0x442415));if(this['md5']!==_0xc30a2a){this[_0x18fc('0x1')]=_0xc30a2a;io['to'](util[_0x18fc('0x18')](_0x18fc('0x19'),_0x442415[_0x18fc('0x6')]))[_0x18fc('0x1a')](_0x18fc('0x1b'),_0x442415);}};module['exports']=OpenchannelQueue;