85b16a9cefa21677998f9ef04b6848e9fe532c4b
[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 _0x0d08=['exports','util','ioredis','../../../config/environment','redis','name','timeout','strategy','beepall','Agents','md5','updateRouting','prototype','mapAgentsId','_rr','map','updateRealtime','loggedIn','paused','length','online','openchannelPause','available','stringify','format','openchannel:queue:%s','emit','openchannel_queue:save'];(function(_0x4e9310,_0x5296e4){var _0x346b79=function(_0x2b0d41){while(--_0x2b0d41){_0x4e9310['push'](_0x4e9310['shift']());}};_0x346b79(++_0x5296e4);}(_0x0d08,0xa9));var _0x80d0=function(_0x4565bf,_0x5ad9d6){_0x4565bf=_0x4565bf-0x0;var _0x5610ba=_0x0d08[_0x4565bf];return _0x5610ba;};'use strict';var _=require('lodash');var md5=require('md5');var util=require(_0x80d0('0x0'));var Redis=require(_0x80d0('0x1'));var config=require(_0x80d0('0x2'));config[_0x80d0('0x3')]=_['defaults'](config[_0x80d0('0x3')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function OpenchannelQueue(_0x509e8){this['id']=_0x509e8['id']||0x0;this[_0x80d0('0x4')]=_0x509e8[_0x80d0('0x4')]||'';this[_0x80d0('0x5')]=_0x509e8[_0x80d0('0x5')]||0xa;this[_0x80d0('0x6')]=_0x509e8[_0x80d0('0x6')]||_0x80d0('0x7');this['Agents']=_0x509e8[_0x80d0('0x8')];this['mapAgentsId']={};this['waiting']=0x0;this[_0x80d0('0x9')]='';this[_0x80d0('0xa')]();this['updateRealtime']();}OpenchannelQueue[_0x80d0('0xb')][_0x80d0('0xa')]=function(){var _0x27e88c=this[_0x80d0('0xc')][_0x80d0('0xd')];this[_0x80d0('0xc')]=_[_0x80d0('0xe')](this['Agents'],'id');this[_0x80d0('0xc')][_0x80d0('0xd')]=_0x27e88c;};OpenchannelQueue['prototype'][_0x80d0('0xf')]=function(){this[_0x80d0('0x10')]=0x0;this[_0x80d0('0x11')]=0x0;for(var _0x4df878=0x0;_0x4df878<this['Agents'][_0x80d0('0x12')];_0x4df878+=0x1){if(this[_0x80d0('0x8')][_0x4df878][_0x80d0('0x13')]){this[_0x80d0('0x10')]+=0x1;}if(this[_0x80d0('0x8')][_0x4df878][_0x80d0('0x14')]){this[_0x80d0('0x11')]+=0x1;}}this[_0x80d0('0x15')]=this[_0x80d0('0x10')]-this[_0x80d0('0x11')];this[_0x80d0('0x15')]=this['available']>=0x0?this['available']:0x0;var _0x22bccb={'id':this['id'],'available':this[_0x80d0('0x15')],'loggedIn':this[_0x80d0('0x10')],'name':this['name'],'paused':this[_0x80d0('0x11')],'waiting':this['waiting']};var _0x59cbaa=md5(JSON[_0x80d0('0x16')](_0x22bccb));if(this[_0x80d0('0x9')]!==_0x59cbaa){this[_0x80d0('0x9')]=_0x59cbaa;io['to'](util[_0x80d0('0x17')](_0x80d0('0x18'),_0x22bccb[_0x80d0('0x4')]))[_0x80d0('0x19')](_0x80d0('0x1a'),_0x22bccb);}};module[_0x80d0('0x1b')]=OpenchannelQueue;