Built motion from commit (unavailable).|2.4.17
[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 _0x8d07=['../../../config/environment','redis','defaults','localhost','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map','updateRealtime','paused','online','loggedIn','available','name','stringify','exports','lodash','md5','util','ioredis'];(function(_0x565c49,_0x54acd0){var _0x20ca34=function(_0x42f7e1){while(--_0x42f7e1){_0x565c49['push'](_0x565c49['shift']());}};_0x20ca34(++_0x54acd0);}(_0x8d07,0xb2));var _0x78d0=function(_0x1c546c,_0x5c57cb){_0x1c546c=_0x1c546c-0x0;var _0x2cc384=_0x8d07[_0x1c546c];return _0x2cc384;};'use strict';var _=require(_0x78d0('0x0'));var md5=require(_0x78d0('0x1'));var util=require(_0x78d0('0x2'));var Redis=require(_0x78d0('0x3'));var config=require(_0x78d0('0x4'));config[_0x78d0('0x5')]=_[_0x78d0('0x6')](config[_0x78d0('0x5')],{'host':_0x78d0('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));function OpenchannelQueue(_0x14fc1f){this['id']=_0x14fc1f['id']||0x0;this['name']=_0x14fc1f['name']||'';this[_0x78d0('0x8')]=_0x14fc1f[_0x78d0('0x8')]||0xa;this['strategy']=_0x14fc1f[_0x78d0('0x9')]||_0x78d0('0xa');this[_0x78d0('0xb')]=_0x14fc1f[_0x78d0('0xb')];this[_0x78d0('0xc')]={};this[_0x78d0('0xd')]=0x0;this[_0x78d0('0x1')]='';this[_0x78d0('0xe')]();this['updateRealtime']();}OpenchannelQueue[_0x78d0('0xf')][_0x78d0('0xe')]=function(){var _0x4b43d2=this[_0x78d0('0xc')][_0x78d0('0x10')];this[_0x78d0('0xc')]=_[_0x78d0('0x11')](this['Agents'],'id');this[_0x78d0('0xc')][_0x78d0('0x10')]=_0x4b43d2;};OpenchannelQueue[_0x78d0('0xf')][_0x78d0('0x12')]=function(){this['loggedIn']=0x0;this[_0x78d0('0x13')]=0x0;for(var _0xd9fe79=0x0;_0xd9fe79<this['Agents']['length'];_0xd9fe79+=0x1){if(this[_0x78d0('0xb')][_0xd9fe79][_0x78d0('0x14')]){this[_0x78d0('0x15')]+=0x1;}if(this[_0x78d0('0xb')][_0xd9fe79]['openchannelPause']){this[_0x78d0('0x13')]+=0x1;}}this[_0x78d0('0x16')]=this[_0x78d0('0x15')]-this[_0x78d0('0x13')];this[_0x78d0('0x16')]=this[_0x78d0('0x16')]>=0x0?this[_0x78d0('0x16')]:0x0;var _0x56e99d={'id':this['id'],'available':this[_0x78d0('0x16')],'loggedIn':this[_0x78d0('0x15')],'name':this[_0x78d0('0x17')],'paused':this[_0x78d0('0x13')],'waiting':this[_0x78d0('0xd')]};var _0x1b630a=md5(JSON[_0x78d0('0x18')](_0x56e99d));if(this[_0x78d0('0x1')]!==_0x1b630a){this[_0x78d0('0x1')]=_0x1b630a;io['to'](util['format']('openchannel:queue:%s',_0x56e99d[_0x78d0('0x17')]))['emit']('openchannel_queue:save',_0x56e99d);}};module[_0x78d0('0x19')]=OpenchannelQueue;