Built motion from commit (unavailable).|2.2.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 _0x23ca=['localhost','timeout','strategy','Agents','mapAgentsId','waiting','md5','updateRouting','updateRealtime','prototype','map','_rr','loggedIn','length','online','openchannelPause','paused','available','name','format','openchannel:queue:%s','emit','openchannel_queue:save','exports','lodash','util','../../../config/environment','redis'];(function(_0x29db8f,_0x4c07a4){var _0x2257b8=function(_0x3cff57){while(--_0x3cff57){_0x29db8f['push'](_0x29db8f['shift']());}};_0x2257b8(++_0x4c07a4);}(_0x23ca,0x130));var _0xa23c=function(_0x50af57,_0x57f975){_0x50af57=_0x50af57-0x0;var _0x2d8d16=_0x23ca[_0x50af57];return _0x2d8d16;};'use strict';var _=require(_0xa23c('0x0'));var md5=require('md5');var util=require(_0xa23c('0x1'));var Redis=require('ioredis');var config=require(_0xa23c('0x2'));config[_0xa23c('0x3')]=_['defaults'](config[_0xa23c('0x3')],{'host':_0xa23c('0x4'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xa23c('0x3')]));function OpenchannelQueue(_0xe117ee){this['id']=_0xe117ee['id']||0x0;this['name']=_0xe117ee['name']||'';this[_0xa23c('0x5')]=_0xe117ee[_0xa23c('0x5')]||0xa;this[_0xa23c('0x6')]=_0xe117ee[_0xa23c('0x6')]||'beepall';this['Agents']=_0xe117ee[_0xa23c('0x7')];this[_0xa23c('0x8')]={};this[_0xa23c('0x9')]=0x0;this[_0xa23c('0xa')]='';this[_0xa23c('0xb')]();this[_0xa23c('0xc')]();}OpenchannelQueue[_0xa23c('0xd')][_0xa23c('0xb')]=function(){var _0x16ff53=this[_0xa23c('0x8')]['_rr'];this[_0xa23c('0x8')]=_[_0xa23c('0xe')](this['Agents'],'id');this['mapAgentsId'][_0xa23c('0xf')]=_0x16ff53;};OpenchannelQueue[_0xa23c('0xd')][_0xa23c('0xc')]=function(){this[_0xa23c('0x10')]=0x0;this['paused']=0x0;for(var _0x464fb2=0x0;_0x464fb2<this[_0xa23c('0x7')][_0xa23c('0x11')];_0x464fb2+=0x1){if(this[_0xa23c('0x7')][_0x464fb2][_0xa23c('0x12')]){this[_0xa23c('0x10')]+=0x1;}if(this['Agents'][_0x464fb2][_0xa23c('0x13')]){this[_0xa23c('0x14')]+=0x1;}}this[_0xa23c('0x15')]=this[_0xa23c('0x10')]-this[_0xa23c('0x14')];this[_0xa23c('0x15')]=this[_0xa23c('0x15')]>=0x0?this['available']:0x0;var _0x2d0294={'id':this['id'],'available':this[_0xa23c('0x15')],'loggedIn':this[_0xa23c('0x10')],'name':this[_0xa23c('0x16')],'paused':this[_0xa23c('0x14')],'waiting':this['waiting']};var _0x3bd01d=md5(JSON['stringify'](_0x2d0294));if(this['md5']!==_0x3bd01d){this[_0xa23c('0xa')]=_0x3bd01d;io['to'](util[_0xa23c('0x17')](_0xa23c('0x18'),_0x2d0294['name']))[_0xa23c('0x19')](_0xa23c('0x1a'),_0x2d0294);}};module[_0xa23c('0x1b')]=OpenchannelQueue;