Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / services / routing / model / chatQueue.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 _0x9636=['loggedIn','paused','length','chatPause','available','emit','chat_queue:save','exports','lodash','md5','util','ioredis','../../../config/environment','redis','localhost','name','timeout','strategy','Agents','mapAgentsId','waiting','updateRouting','updateRealtime','prototype','_rr'];(function(_0x137fb5,_0x2ef78d){var _0x49bcf1=function(_0x41efe0){while(--_0x41efe0){_0x137fb5['push'](_0x137fb5['shift']());}};_0x49bcf1(++_0x2ef78d);}(_0x9636,0x102));var _0x6963=function(_0x53cf8e,_0x3d290f){_0x53cf8e=_0x53cf8e-0x0;var _0x459197=_0x9636[_0x53cf8e];return _0x459197;};'use strict';var _=require(_0x6963('0x0'));var md5=require(_0x6963('0x1'));var util=require(_0x6963('0x2'));var Redis=require(_0x6963('0x3'));var config=require(_0x6963('0x4'));config[_0x6963('0x5')]=_['defaults'](config[_0x6963('0x5')],{'host':_0x6963('0x6'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0x6963('0x5')]));function ChatQueue(_0x2f943f){this['id']=_0x2f943f['id']||0x0;this[_0x6963('0x7')]=_0x2f943f['name']||'';this['timeout']=_0x2f943f[_0x6963('0x8')]||0xa;this['strategy']=_0x2f943f[_0x6963('0x9')]||'beepall';this[_0x6963('0xa')]=_0x2f943f[_0x6963('0xa')];this[_0x6963('0xb')]={};this[_0x6963('0xc')]=0x0;this[_0x6963('0x1')]='';this[_0x6963('0xd')]();this[_0x6963('0xe')]();}ChatQueue[_0x6963('0xf')][_0x6963('0xd')]=function(){var _0x2797fb=this['mapAgentsId'][_0x6963('0x10')];this['mapAgentsId']=_['map'](this['Agents'],'id');this['mapAgentsId'][_0x6963('0x10')]=_0x2797fb;};ChatQueue[_0x6963('0xf')][_0x6963('0xe')]=function(){this[_0x6963('0x11')]=0x0;this[_0x6963('0x12')]=0x0;for(var _0x553c13=0x0;_0x553c13<this['Agents'][_0x6963('0x13')];_0x553c13+=0x1){if(this[_0x6963('0xa')][_0x553c13]['online']){this['loggedIn']+=0x1;}if(this['Agents'][_0x553c13][_0x6963('0x14')]){this['paused']+=0x1;}}this[_0x6963('0x15')]=this[_0x6963('0x11')]-this['paused'];this[_0x6963('0x15')]=this[_0x6963('0x15')]>=0x0?this[_0x6963('0x15')]:0x0;var _0x901e4e={'id':this['id'],'available':this['available'],'loggedIn':this[_0x6963('0x11')],'name':this['name'],'paused':this[_0x6963('0x12')],'waiting':this[_0x6963('0xc')]};var _0x3d720b=md5(JSON['stringify'](_0x901e4e));if(this[_0x6963('0x1')]!==_0x3d720b){this['md5']=_0x3d720b;io['to'](util['format']('chat:queue:%s',_0x901e4e[_0x6963('0x7')]))[_0x6963('0x16')](_0x6963('0x17'),_0x901e4e);}};module[_0x6963('0x18')]=ChatQueue;