Built motion from commit (unavailable).|2.5.0
[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 _0x45ca=['lodash','../../../config/environment','redis','defaults','localhost','socket.io-emitter','name','timeout','strategy','beepall','Agents','mapAgentsId','waiting','md5','updateRealtime','map','_rr','loggedIn','paused','length','online','openchannelPause','available','stringify','format','openchannel:queue:%s','exports'];(function(_0x22b49c,_0x3084d7){var _0xca5772=function(_0x21724c){while(--_0x21724c){_0x22b49c['push'](_0x22b49c['shift']());}};_0xca5772(++_0x3084d7);}(_0x45ca,0xbd));var _0xa45c=function(_0x19e35c,_0x29cd1e){_0x19e35c=_0x19e35c-0x0;var _0x3e1fe8=_0x45ca[_0x19e35c];return _0x3e1fe8;};'use strict';var _=require(_0xa45c('0x0'));var md5=require('md5');var util=require('util');var Redis=require('ioredis');var config=require(_0xa45c('0x1'));config[_0xa45c('0x2')]=_[_0xa45c('0x3')](config[_0xa45c('0x2')],{'host':_0xa45c('0x4'),'port':0x18eb});var io=require(_0xa45c('0x5'))(new Redis(config['redis']));function OpenchannelQueue(_0x3867f1){this['id']=_0x3867f1['id']||0x0;this[_0xa45c('0x6')]=_0x3867f1[_0xa45c('0x6')]||'';this[_0xa45c('0x7')]=_0x3867f1[_0xa45c('0x7')]||0xa;this[_0xa45c('0x8')]=_0x3867f1['strategy']||_0xa45c('0x9');this[_0xa45c('0xa')]=_0x3867f1[_0xa45c('0xa')];this[_0xa45c('0xb')]={};this[_0xa45c('0xc')]=0x0;this[_0xa45c('0xd')]='';this['updateRouting']();this[_0xa45c('0xe')]();}OpenchannelQueue['prototype']['updateRouting']=function(){var _0x347a40=this[_0xa45c('0xb')]['_rr'];this['mapAgentsId']=_[_0xa45c('0xf')](this[_0xa45c('0xa')],'id');this[_0xa45c('0xb')][_0xa45c('0x10')]=_0x347a40;};OpenchannelQueue['prototype'][_0xa45c('0xe')]=function(){this[_0xa45c('0x11')]=0x0;this[_0xa45c('0x12')]=0x0;for(var _0x43c377=0x0;_0x43c377<this[_0xa45c('0xa')][_0xa45c('0x13')];_0x43c377+=0x1){if(this['Agents'][_0x43c377][_0xa45c('0x14')]){this[_0xa45c('0x11')]+=0x1;}if(this[_0xa45c('0xa')][_0x43c377][_0xa45c('0x15')]){this[_0xa45c('0x12')]+=0x1;}}this['available']=this[_0xa45c('0x11')]-this[_0xa45c('0x12')];this[_0xa45c('0x16')]=this[_0xa45c('0x16')]>=0x0?this[_0xa45c('0x16')]:0x0;var _0x106865={'id':this['id'],'available':this[_0xa45c('0x16')],'loggedIn':this[_0xa45c('0x11')],'name':this[_0xa45c('0x6')],'paused':this[_0xa45c('0x12')],'waiting':this[_0xa45c('0xc')]};var _0x39a82a=md5(JSON[_0xa45c('0x17')](_0x106865));if(this[_0xa45c('0xd')]!==_0x39a82a){this[_0xa45c('0xd')]=_0x39a82a;io['to'](util[_0xa45c('0x18')](_0xa45c('0x19'),_0x106865[_0xa45c('0x6')]))['emit']('openchannel_queue:save',_0x106865);}};module[_0xa45c('0x1a')]=OpenchannelQueue;