Built motion from commit 26159a51.|2.5.44
[motion2.git] / server / services / agi / server.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 _0xbf96=['events','EventEmitter','./channel','emit','error','E_AGI_ARGUMENT_PORT','createServer','listen','listening','connection','getConnections','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','destroy','close','E_AGI_SERVER_CLOSE','nextTick','inherits','exports','net'];(function(_0x5b2e3d,_0x2d7f7b){var _0x35a13c=function(_0x831acc){while(--_0x831acc){_0x5b2e3d['push'](_0x5b2e3d['shift']());}};_0x35a13c(++_0x2d7f7b);}(_0xbf96,0xdb));var _0x6bf9=function(_0x469e53,_0x1b0034){_0x469e53=_0x469e53-0x0;var _0x1bf91b=_0xbf96[_0x469e53];return _0x1bf91b;};'use strict';var util=require('util');var net=require(_0x6bf9('0x0'));var EventEmitter=require(_0x6bf9('0x1'))[_0x6bf9('0x2')];var AGIError=require('./error');var AGIChannel=require(_0x6bf9('0x3'));var AGIServer=function(_0x22f1ff,_0x3aaa41,_0x1e11bd){var _0x3b5f8e=this,_0x22f1ff=_0x22f1ff||0x11dd,_0x3aaa41=_0x3aaa41||'127.0.0.1',_0x37da1a=null,_0x4659b2=0x0;EventEmitter['call'](_0x3b5f8e);function _0x240b7c(){if(!_0x22f1ff){_0x3b5f8e[_0x6bf9('0x4')](_0x6bf9('0x5'),new AGIError(_0x6bf9('0x6')));return![];}_0x37da1a=net[_0x6bf9('0x7')]();_0x37da1a[_0x6bf9('0x8')](_0x22f1ff,_0x3aaa41);_0x37da1a['on'](_0x6bf9('0x9'),function(){_0x3b5f8e[_0x6bf9('0x4')]('listening');});_0x37da1a['on'](_0x6bf9('0xa'),function(_0x3e4e80){_0x37da1a[_0x6bf9('0xb')](function(_0x3def91,_0x22ea6a){if(_0x3def91){_0x3b5f8e[_0x6bf9('0x4')](_0x6bf9('0x5'),new AGIError(_0x6bf9('0xc'),_0x3def91));}else if(_0x1e11bd&&_0x1e11bd<0x0){_0x3b5f8e[_0x6bf9('0x4')](_0x6bf9('0x5'),new AGIError(_0x6bf9('0xd')));_0x3e4e80[_0x6bf9('0xe')]();}else if(_0x1e11bd&&_0x1e11bd>0x0&&_0x1e11bd<_0x22ea6a){_0x4659b2+=0x1;_0x3b5f8e[_0x6bf9('0x4')](_0x6bf9('0x5'),new AGIError('E_AGI_SERVER_MAXCONNECTION',_0x4659b2));_0x3e4e80[_0x6bf9('0xe')]();}else{var _0x150a5b=new AGIChannel(_0x3e4e80);_0x150a5b['on']('ready',function(){_0x3b5f8e[_0x6bf9('0x4')](_0x6bf9('0xa'),_0x150a5b);});}});});_0x37da1a['on']('error',function(_0x216e8c){_0x3b5f8e[_0x6bf9('0x4')]('error',new AGIError(_0x6bf9('0xc'),_0x216e8c['code']));});_0x37da1a['on'](_0x6bf9('0xf'),function(){_0x3b5f8e['emit'](_0x6bf9('0xf'),new AGIError(_0x6bf9('0x10')));});}process[_0x6bf9('0x11')](function(){_0x240b7c();});};util[_0x6bf9('0x12')](AGIServer,EventEmitter);module[_0x6bf9('0x13')]=function(_0x1aeac5,_0x57ba23,_0x3d0e4a){return new AGIServer(_0x1aeac5,_0x57ba23,_0x3d0e4a);};