Built motion from commit (unavailable).|2.5.31
[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 _0x1807=['emit','openchannel_queue:save','exports','lodash','ioredis','../../../config/environment','defaults','redis','localhost','name','timeout','strategy','beepall','Agents','waiting','updateRouting','prototype','mapAgentsId','_rr','map','updateRealtime','loggedIn','paused','online','openchannelPause','available','md5','format','openchannel:queue:%s'];(function(_0x483d69,_0x26d1ae){var _0x17743a=function(_0x137887){while(--_0x137887){_0x483d69['push'](_0x483d69['shift']());}};_0x17743a(++_0x26d1ae);}(_0x1807,0x15f));var _0x7180=function(_0x38e5ee,_0x3cd0cb){_0x38e5ee=_0x38e5ee-0x0;var _0x85812d=_0x1807[_0x38e5ee];return _0x85812d;};'use strict';var _=require(_0x7180('0x0'));var md5=require('md5');var util=require('util');var Redis=require(_0x7180('0x1'));var config=require(_0x7180('0x2'));config['redis']=_[_0x7180('0x3')](config[_0x7180('0x4')],{'host':_0x7180('0x5'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x7180('0x4')]));function OpenchannelQueue(_0x3e82b1){this['id']=_0x3e82b1['id']||0x0;this[_0x7180('0x6')]=_0x3e82b1['name']||'';this[_0x7180('0x7')]=_0x3e82b1[_0x7180('0x7')]||0xa;this[_0x7180('0x8')]=_0x3e82b1[_0x7180('0x8')]||_0x7180('0x9');this[_0x7180('0xa')]=_0x3e82b1['Agents'];this['mapAgentsId']={};this[_0x7180('0xb')]=0x0;this['md5']='';this[_0x7180('0xc')]();this['updateRealtime']();}OpenchannelQueue[_0x7180('0xd')]['updateRouting']=function(){var _0x3d82fd=this[_0x7180('0xe')][_0x7180('0xf')];this[_0x7180('0xe')]=_[_0x7180('0x10')](this[_0x7180('0xa')],'id');this['mapAgentsId'][_0x7180('0xf')]=_0x3d82fd;};OpenchannelQueue[_0x7180('0xd')][_0x7180('0x11')]=function(){this[_0x7180('0x12')]=0x0;this[_0x7180('0x13')]=0x0;for(var _0x12d63a=0x0;_0x12d63a<this[_0x7180('0xa')]['length'];_0x12d63a+=0x1){if(this[_0x7180('0xa')][_0x12d63a][_0x7180('0x14')]){this[_0x7180('0x12')]+=0x1;}if(this[_0x7180('0xa')][_0x12d63a][_0x7180('0x15')]){this[_0x7180('0x13')]+=0x1;}}this['available']=this[_0x7180('0x12')]-this['paused'];this[_0x7180('0x16')]=this[_0x7180('0x16')]>=0x0?this[_0x7180('0x16')]:0x0;var _0x147724={'id':this['id'],'available':this[_0x7180('0x16')],'loggedIn':this['loggedIn'],'name':this[_0x7180('0x6')],'paused':this[_0x7180('0x13')],'waiting':this[_0x7180('0xb')]};var _0x261d99=md5(JSON['stringify'](_0x147724));if(this[_0x7180('0x17')]!==_0x261d99){this[_0x7180('0x17')]=_0x261d99;io['to'](util[_0x7180('0x18')](_0x7180('0x19'),_0x147724[_0x7180('0x6')]))[_0x7180('0x1a')](_0x7180('0x1b'),_0x147724);}};module[_0x7180('0x1c')]=OpenchannelQueue;