Built motion from commit (unavailable).|2.5.10
[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 _0x0d6a=['_rr','updateRealtime','loggedIn','paused','length','online','available','stringify','format','emit','exports','lodash','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','Agents','mapAgentsId','waiting','md5','updateRouting','prototype'];(function(_0x4bca5c,_0x6c6e4f){var _0x3a1d8a=function(_0x559ee5){while(--_0x559ee5){_0x4bca5c['push'](_0x4bca5c['shift']());}};_0x3a1d8a(++_0x6c6e4f);}(_0x0d6a,0xa7));var _0xa0d6=function(_0x39096d,_0x51f8a0){_0x39096d=_0x39096d-0x0;var _0x13da4f=_0x0d6a[_0x39096d];return _0x13da4f;};'use strict';var _=require(_0xa0d6('0x0'));var md5=require('md5');var util=require('util');var Redis=require(_0xa0d6('0x1'));var config=require(_0xa0d6('0x2'));config[_0xa0d6('0x3')]=_[_0xa0d6('0x4')](config[_0xa0d6('0x3')],{'host':_0xa0d6('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xa0d6('0x3')]));function OpenchannelQueue(_0x5d95a4){this['id']=_0x5d95a4['id']||0x0;this[_0xa0d6('0x6')]=_0x5d95a4[_0xa0d6('0x6')]||'';this[_0xa0d6('0x7')]=_0x5d95a4['timeout']||0xa;this[_0xa0d6('0x8')]=_0x5d95a4['strategy']||'beepall';this[_0xa0d6('0x9')]=_0x5d95a4[_0xa0d6('0x9')];this[_0xa0d6('0xa')]={};this[_0xa0d6('0xb')]=0x0;this[_0xa0d6('0xc')]='';this[_0xa0d6('0xd')]();this['updateRealtime']();}OpenchannelQueue[_0xa0d6('0xe')][_0xa0d6('0xd')]=function(){var _0x20395e=this['mapAgentsId'][_0xa0d6('0xf')];this[_0xa0d6('0xa')]=_['map'](this[_0xa0d6('0x9')],'id');this[_0xa0d6('0xa')][_0xa0d6('0xf')]=_0x20395e;};OpenchannelQueue[_0xa0d6('0xe')][_0xa0d6('0x10')]=function(){this[_0xa0d6('0x11')]=0x0;this[_0xa0d6('0x12')]=0x0;for(var _0x54c9e8=0x0;_0x54c9e8<this[_0xa0d6('0x9')][_0xa0d6('0x13')];_0x54c9e8+=0x1){if(this[_0xa0d6('0x9')][_0x54c9e8][_0xa0d6('0x14')]){this[_0xa0d6('0x11')]+=0x1;}if(this[_0xa0d6('0x9')][_0x54c9e8]['openchannelPause']){this['paused']+=0x1;}}this[_0xa0d6('0x15')]=this['loggedIn']-this['paused'];this[_0xa0d6('0x15')]=this['available']>=0x0?this[_0xa0d6('0x15')]:0x0;var _0x535c27={'id':this['id'],'available':this[_0xa0d6('0x15')],'loggedIn':this[_0xa0d6('0x11')],'name':this[_0xa0d6('0x6')],'paused':this[_0xa0d6('0x12')],'waiting':this[_0xa0d6('0xb')]};var _0x53f869=md5(JSON[_0xa0d6('0x16')](_0x535c27));if(this[_0xa0d6('0xc')]!==_0x53f869){this[_0xa0d6('0xc')]=_0x53f869;io['to'](util[_0xa0d6('0x17')]('openchannel:queue:%s',_0x535c27[_0xa0d6('0x6')]))[_0xa0d6('0x18')]('openchannel_queue:save',_0x535c27);}};module[_0xa0d6('0x19')]=OpenchannelQueue;