Built motion from commit (unavailable).|2.5.11
[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 _0xbd02=['map','prototype','loggedIn','paused','length','online','openchannelPause','available','stringify','format','emit','openchannel_queue:save','lodash','md5','ioredis','../../../config/environment','redis','localhost','name','timeout','strategy','Agents','waiting','updateRouting','updateRealtime','mapAgentsId','_rr'];(function(_0x5e1bca,_0xa95e2b){var _0x44aed8=function(_0x31f682){while(--_0x31f682){_0x5e1bca['push'](_0x5e1bca['shift']());}};_0x44aed8(++_0xa95e2b);}(_0xbd02,0x93));var _0x2bd0=function(_0x465a0c,_0x19d4d5){_0x465a0c=_0x465a0c-0x0;var _0x1e202e=_0xbd02[_0x465a0c];return _0x1e202e;};'use strict';var _=require(_0x2bd0('0x0'));var md5=require(_0x2bd0('0x1'));var util=require('util');var Redis=require(_0x2bd0('0x2'));var config=require(_0x2bd0('0x3'));config[_0x2bd0('0x4')]=_['defaults'](config['redis'],{'host':_0x2bd0('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x2bd0('0x4')]));function OpenchannelQueue(_0x8eb67d){this['id']=_0x8eb67d['id']||0x0;this[_0x2bd0('0x6')]=_0x8eb67d[_0x2bd0('0x6')]||'';this[_0x2bd0('0x7')]=_0x8eb67d[_0x2bd0('0x7')]||0xa;this[_0x2bd0('0x8')]=_0x8eb67d[_0x2bd0('0x8')]||'beepall';this[_0x2bd0('0x9')]=_0x8eb67d[_0x2bd0('0x9')];this['mapAgentsId']={};this[_0x2bd0('0xa')]=0x0;this[_0x2bd0('0x1')]='';this[_0x2bd0('0xb')]();this[_0x2bd0('0xc')]();}OpenchannelQueue['prototype'][_0x2bd0('0xb')]=function(){var _0xc3c98a=this[_0x2bd0('0xd')][_0x2bd0('0xe')];this[_0x2bd0('0xd')]=_[_0x2bd0('0xf')](this[_0x2bd0('0x9')],'id');this[_0x2bd0('0xd')][_0x2bd0('0xe')]=_0xc3c98a;};OpenchannelQueue[_0x2bd0('0x10')][_0x2bd0('0xc')]=function(){this[_0x2bd0('0x11')]=0x0;this[_0x2bd0('0x12')]=0x0;for(var _0x4bdeb6=0x0;_0x4bdeb6<this[_0x2bd0('0x9')][_0x2bd0('0x13')];_0x4bdeb6+=0x1){if(this[_0x2bd0('0x9')][_0x4bdeb6][_0x2bd0('0x14')]){this['loggedIn']+=0x1;}if(this[_0x2bd0('0x9')][_0x4bdeb6][_0x2bd0('0x15')]){this[_0x2bd0('0x12')]+=0x1;}}this['available']=this[_0x2bd0('0x11')]-this[_0x2bd0('0x12')];this[_0x2bd0('0x16')]=this[_0x2bd0('0x16')]>=0x0?this['available']:0x0;var _0x53789b={'id':this['id'],'available':this['available'],'loggedIn':this[_0x2bd0('0x11')],'name':this[_0x2bd0('0x6')],'paused':this['paused'],'waiting':this[_0x2bd0('0xa')]};var _0x311344=md5(JSON[_0x2bd0('0x17')](_0x53789b));if(this[_0x2bd0('0x1')]!==_0x311344){this[_0x2bd0('0x1')]=_0x311344;io['to'](util[_0x2bd0('0x18')]('openchannel:queue:%s',_0x53789b[_0x2bd0('0x6')]))[_0x2bd0('0x19')](_0x2bd0('0x1a'),_0x53789b);}};module['exports']=OpenchannelQueue;