114f541066b5e96d40c795d0b31f03e7f2cf280b
[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 _0xf397=['prototype','updateRealtime','loggedIn','paused','length','available','stringify','format','openchannel:queue:%s','openchannel_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','defaults','localhost','name','timeout','strategy','beepall','Agents','waiting','updateRouting','mapAgentsId'];(function(_0x2786d3,_0x31fcc3){var _0x5ccbda=function(_0x39ab92){while(--_0x39ab92){_0x2786d3['push'](_0x2786d3['shift']());}};_0x5ccbda(++_0x31fcc3);}(_0xf397,0x16a));var _0x7f39=function(_0x2d0abe,_0x42cfc9){_0x2d0abe=_0x2d0abe-0x0;var _0x5ee2b8=_0xf397[_0x2d0abe];return _0x5ee2b8;};'use strict';var _=require(_0x7f39('0x0'));var md5=require(_0x7f39('0x1'));var util=require(_0x7f39('0x2'));var Redis=require(_0x7f39('0x3'));var config=require(_0x7f39('0x4'));config[_0x7f39('0x5')]=_[_0x7f39('0x6')](config[_0x7f39('0x5')],{'host':_0x7f39('0x7'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x7f39('0x5')]));function OpenchannelQueue(_0x2780d4){this['id']=_0x2780d4['id']||0x0;this['name']=_0x2780d4[_0x7f39('0x8')]||'';this[_0x7f39('0x9')]=_0x2780d4['timeout']||0xa;this['strategy']=_0x2780d4[_0x7f39('0xa')]||_0x7f39('0xb');this['Agents']=_0x2780d4[_0x7f39('0xc')];this['mapAgentsId']={};this[_0x7f39('0xd')]=0x0;this[_0x7f39('0x1')]='';this[_0x7f39('0xe')]();this['updateRealtime']();}OpenchannelQueue['prototype'][_0x7f39('0xe')]=function(){var _0x3c4a6c=this[_0x7f39('0xf')]['_rr'];this[_0x7f39('0xf')]=_['map'](this[_0x7f39('0xc')],'id');this[_0x7f39('0xf')]['_rr']=_0x3c4a6c;};OpenchannelQueue[_0x7f39('0x10')][_0x7f39('0x11')]=function(){this[_0x7f39('0x12')]=0x0;this[_0x7f39('0x13')]=0x0;for(var _0x54a06b=0x0;_0x54a06b<this[_0x7f39('0xc')][_0x7f39('0x14')];_0x54a06b+=0x1){if(this['Agents'][_0x54a06b]['online']){this[_0x7f39('0x12')]+=0x1;}if(this[_0x7f39('0xc')][_0x54a06b]['openchannelPause']){this['paused']+=0x1;}}this[_0x7f39('0x15')]=this[_0x7f39('0x12')]-this[_0x7f39('0x13')];this[_0x7f39('0x15')]=this[_0x7f39('0x15')]>=0x0?this[_0x7f39('0x15')]:0x0;var _0x49d729={'id':this['id'],'available':this[_0x7f39('0x15')],'loggedIn':this[_0x7f39('0x12')],'name':this[_0x7f39('0x8')],'paused':this[_0x7f39('0x13')],'waiting':this[_0x7f39('0xd')]};var _0x1da052=md5(JSON[_0x7f39('0x16')](_0x49d729));if(this[_0x7f39('0x1')]!==_0x1da052){this[_0x7f39('0x1')]=_0x1da052;io['to'](util[_0x7f39('0x17')](_0x7f39('0x18'),_0x49d729['name']))['emit'](_0x7f39('0x19'),_0x49d729);}};module[_0x7f39('0x1a')]=OpenchannelQueue;