Built motion from commit (unavailable).|2.5.31
[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 _0xf197=['close','nextTick','inherits','exports','util','net','events','./channel','127.0.0.1','call','emit','error','createServer','listen','listening','connection','getConnections','E_AGI_SERVER_ERROR','destroy','code'];(function(_0x1b2282,_0x466aa0){var _0x161391=function(_0x21b161){while(--_0x21b161){_0x1b2282['push'](_0x1b2282['shift']());}};_0x161391(++_0x466aa0);}(_0xf197,0x130));var _0x7f19=function(_0x159bad,_0x45d3f2){_0x159bad=_0x159bad-0x0;var _0x112694=_0xf197[_0x159bad];return _0x112694;};'use strict';var util=require(_0x7f19('0x0'));var net=require(_0x7f19('0x1'));var EventEmitter=require(_0x7f19('0x2'))['EventEmitter'];var AGIError=require('./error');var AGIChannel=require(_0x7f19('0x3'));var AGIServer=function(_0x5a184b,_0x4b7af0,_0x5715b0){var _0x152a30=this,_0x5a184b=_0x5a184b||0x11dd,_0x4b7af0=_0x4b7af0||_0x7f19('0x4'),_0x1a3591=null,_0x3c076e=0x0;EventEmitter[_0x7f19('0x5')](_0x152a30);function _0x39c494(){if(!_0x5a184b){_0x152a30[_0x7f19('0x6')](_0x7f19('0x7'),new AGIError('E_AGI_ARGUMENT_PORT'));return![];}_0x1a3591=net[_0x7f19('0x8')]();_0x1a3591[_0x7f19('0x9')](_0x5a184b,_0x4b7af0);_0x1a3591['on'](_0x7f19('0xa'),function(){_0x152a30['emit'](_0x7f19('0xa'));});_0x1a3591['on'](_0x7f19('0xb'),function(_0x1e8dd9){_0x1a3591[_0x7f19('0xc')](function(_0x56ce22,_0x14bc93){if(_0x56ce22){_0x152a30['emit'](_0x7f19('0x7'),new AGIError(_0x7f19('0xd'),_0x56ce22));}else if(_0x5715b0&&_0x5715b0<0x0){_0x152a30[_0x7f19('0x6')]('error',new AGIError('E_AGI_SERVER_VOICE_DISABLED'));_0x1e8dd9[_0x7f19('0xe')]();}else if(_0x5715b0&&_0x5715b0>0x0&&_0x5715b0<_0x14bc93){_0x3c076e+=0x1;_0x152a30[_0x7f19('0x6')](_0x7f19('0x7'),new AGIError('E_AGI_SERVER_MAXCONNECTION',_0x3c076e));_0x1e8dd9[_0x7f19('0xe')]();}else{var _0x20fe84=new AGIChannel(_0x1e8dd9);_0x20fe84['on']('ready',function(){_0x152a30[_0x7f19('0x6')](_0x7f19('0xb'),_0x20fe84);});}});});_0x1a3591['on'](_0x7f19('0x7'),function(_0x5c0b64){_0x152a30[_0x7f19('0x6')]('error',new AGIError(_0x7f19('0xd'),_0x5c0b64[_0x7f19('0xf')]));});_0x1a3591['on'](_0x7f19('0x10'),function(){_0x152a30[_0x7f19('0x6')](_0x7f19('0x10'),new AGIError('E_AGI_SERVER_CLOSE'));});}process[_0x7f19('0x11')](function(){_0x39c494();});};util[_0x7f19('0x12')](AGIServer,EventEmitter);module[_0x7f19('0x13')]=function(_0x58bab8,_0x106054,_0x52bcf){return new AGIServer(_0x58bab8,_0x106054,_0x52bcf);};