Built motion from commit (unavailable).|2.5.2
[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 _0xf9bd=['../../../config/environment','redis','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','map','prototype','paused','length','loggedIn','openchannelPause','available','stringify','format','exports','md5','util','ioredis'];(function(_0x381a37,_0x28d4ed){var _0x202bf9=function(_0x374f14){while(--_0x374f14){_0x381a37['push'](_0x381a37['shift']());}};_0x202bf9(++_0x28d4ed);}(_0xf9bd,0xbd));var _0xdf9b=function(_0x44bba3,_0x268372){_0x44bba3=_0x44bba3-0x0;var _0x1b8aeb=_0xf9bd[_0x44bba3];return _0x1b8aeb;};'use strict';var _=require('lodash');var md5=require(_0xdf9b('0x0'));var util=require(_0xdf9b('0x1'));var Redis=require(_0xdf9b('0x2'));var config=require(_0xdf9b('0x3'));config[_0xdf9b('0x4')]=_['defaults'](config[_0xdf9b('0x4')],{'host':'localhost','port':0x18eb});var io=require(_0xdf9b('0x5'))(new Redis(config[_0xdf9b('0x4')]));function OpenchannelQueue(_0x5ba7a8){this['id']=_0x5ba7a8['id']||0x0;this[_0xdf9b('0x6')]=_0x5ba7a8[_0xdf9b('0x6')]||'';this[_0xdf9b('0x7')]=_0x5ba7a8['timeout']||0xa;this[_0xdf9b('0x8')]=_0x5ba7a8[_0xdf9b('0x8')]||_0xdf9b('0x9');this[_0xdf9b('0xa')]=_0x5ba7a8[_0xdf9b('0xa')];this[_0xdf9b('0xb')]={};this[_0xdf9b('0xc')]=0x0;this[_0xdf9b('0x0')]='';this[_0xdf9b('0xd')]();this['updateRealtime']();}OpenchannelQueue['prototype'][_0xdf9b('0xd')]=function(){var _0x744fa0=this[_0xdf9b('0xb')]['_rr'];this[_0xdf9b('0xb')]=_[_0xdf9b('0xe')](this['Agents'],'id');this[_0xdf9b('0xb')]['_rr']=_0x744fa0;};OpenchannelQueue[_0xdf9b('0xf')]['updateRealtime']=function(){this['loggedIn']=0x0;this[_0xdf9b('0x10')]=0x0;for(var _0x113c74=0x0;_0x113c74<this[_0xdf9b('0xa')][_0xdf9b('0x11')];_0x113c74+=0x1){if(this[_0xdf9b('0xa')][_0x113c74]['online']){this[_0xdf9b('0x12')]+=0x1;}if(this[_0xdf9b('0xa')][_0x113c74][_0xdf9b('0x13')]){this[_0xdf9b('0x10')]+=0x1;}}this[_0xdf9b('0x14')]=this[_0xdf9b('0x12')]-this[_0xdf9b('0x10')];this[_0xdf9b('0x14')]=this[_0xdf9b('0x14')]>=0x0?this[_0xdf9b('0x14')]:0x0;var _0x37b796={'id':this['id'],'available':this[_0xdf9b('0x14')],'loggedIn':this[_0xdf9b('0x12')],'name':this['name'],'paused':this[_0xdf9b('0x10')],'waiting':this['waiting']};var _0x5366bf=md5(JSON[_0xdf9b('0x15')](_0x37b796));if(this[_0xdf9b('0x0')]!==_0x5366bf){this[_0xdf9b('0x0')]=_0x5366bf;io['to'](util[_0xdf9b('0x16')]('openchannel:queue:%s',_0x37b796[_0xdf9b('0x6')]))['emit']('openchannel_queue:save',_0x37b796);}};module[_0xdf9b('0x17')]=OpenchannelQueue;