5645edc64b15d4f964fbb70410db629c9952b0d7
[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 _0x8e9d=['emit','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','updateRouting','prototype','_rr','map','updateRealtime','loggedIn','paused','length','openchannelPause','available','stringify','openchannel:queue:%s'];(function(_0x45977c,_0x7eaed0){var _0x399413=function(_0x41cc76){while(--_0x41cc76){_0x45977c['push'](_0x45977c['shift']());}};_0x399413(++_0x7eaed0);}(_0x8e9d,0x8e));var _0xd8e9=function(_0x40f12e,_0x26102d){_0x40f12e=_0x40f12e-0x0;var _0xda42af=_0x8e9d[_0x40f12e];return _0xda42af;};'use strict';var _=require(_0xd8e9('0x0'));var md5=require(_0xd8e9('0x1'));var util=require(_0xd8e9('0x2'));var Redis=require(_0xd8e9('0x3'));var config=require(_0xd8e9('0x4'));config[_0xd8e9('0x5')]=_[_0xd8e9('0x6')](config[_0xd8e9('0x5')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xd8e9('0x5')]));function OpenchannelQueue(_0x19f93e){this['id']=_0x19f93e['id']||0x0;this[_0xd8e9('0x7')]=_0x19f93e[_0xd8e9('0x7')]||'';this[_0xd8e9('0x8')]=_0x19f93e['timeout']||0xa;this[_0xd8e9('0x9')]=_0x19f93e[_0xd8e9('0x9')]||_0xd8e9('0xa');this[_0xd8e9('0xb')]=_0x19f93e[_0xd8e9('0xb')];this[_0xd8e9('0xc')]={};this[_0xd8e9('0xd')]=0x0;this[_0xd8e9('0x1')]='';this[_0xd8e9('0xe')]();this['updateRealtime']();}OpenchannelQueue[_0xd8e9('0xf')][_0xd8e9('0xe')]=function(){var _0x183362=this['mapAgentsId'][_0xd8e9('0x10')];this[_0xd8e9('0xc')]=_[_0xd8e9('0x11')](this[_0xd8e9('0xb')],'id');this[_0xd8e9('0xc')][_0xd8e9('0x10')]=_0x183362;};OpenchannelQueue['prototype'][_0xd8e9('0x12')]=function(){this[_0xd8e9('0x13')]=0x0;this[_0xd8e9('0x14')]=0x0;for(var _0x1034d6=0x0;_0x1034d6<this[_0xd8e9('0xb')][_0xd8e9('0x15')];_0x1034d6+=0x1){if(this[_0xd8e9('0xb')][_0x1034d6]['online']){this[_0xd8e9('0x13')]+=0x1;}if(this[_0xd8e9('0xb')][_0x1034d6][_0xd8e9('0x16')]){this[_0xd8e9('0x14')]+=0x1;}}this[_0xd8e9('0x17')]=this['loggedIn']-this['paused'];this[_0xd8e9('0x17')]=this[_0xd8e9('0x17')]>=0x0?this[_0xd8e9('0x17')]:0x0;var _0x3415cf={'id':this['id'],'available':this[_0xd8e9('0x17')],'loggedIn':this[_0xd8e9('0x13')],'name':this['name'],'paused':this[_0xd8e9('0x14')],'waiting':this[_0xd8e9('0xd')]};var _0x1e60fc=md5(JSON[_0xd8e9('0x18')](_0x3415cf));if(this['md5']!==_0x1e60fc){this['md5']=_0x1e60fc;io['to'](util['format'](_0xd8e9('0x19'),_0x3415cf[_0xd8e9('0x7')]))[_0xd8e9('0x1a')]('openchannel_queue:save',_0x3415cf);}};module[_0xd8e9('0x1b')]=OpenchannelQueue;