Built motion from commit 85328c08.|2.5.50
[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 _0x5e05=['./error','./channel','emit','E_AGI_ARGUMENT_PORT','createServer','listen','listening','connection','getConnections','error','E_AGI_SERVER_ERROR','destroy','E_AGI_SERVER_MAXCONNECTION','ready','code','close','E_AGI_SERVER_CLOSE','nextTick','inherits','exports','net','events'];(function(_0x490dbd,_0x5e4c05){var _0x23a4b9=function(_0x371127){while(--_0x371127){_0x490dbd['push'](_0x490dbd['shift']());}};_0x23a4b9(++_0x5e4c05);}(_0x5e05,0x132));var _0x55e0=function(_0x331ac5,_0x33b3b0){_0x331ac5=_0x331ac5-0x0;var _0x229961=_0x5e05[_0x331ac5];return _0x229961;};'use strict';var util=require('util');var net=require(_0x55e0('0x0'));var EventEmitter=require(_0x55e0('0x1'))['EventEmitter'];var AGIError=require(_0x55e0('0x2'));var AGIChannel=require(_0x55e0('0x3'));var AGIServer=function(_0x4c5a65,_0x2b1493,_0x7cb21a){var _0x415bc5=this,_0x4c5a65=_0x4c5a65||0x11dd,_0x2b1493=_0x2b1493||'127.0.0.1',_0x496a50=null,_0x32d216=0x0;EventEmitter['call'](_0x415bc5);function _0x2d6ebf(){if(!_0x4c5a65){_0x415bc5[_0x55e0('0x4')]('error',new AGIError(_0x55e0('0x5')));return![];}_0x496a50=net[_0x55e0('0x6')]();_0x496a50[_0x55e0('0x7')](_0x4c5a65,_0x2b1493);_0x496a50['on'](_0x55e0('0x8'),function(){_0x415bc5['emit'](_0x55e0('0x8'));});_0x496a50['on'](_0x55e0('0x9'),function(_0x20efcb){_0x496a50[_0x55e0('0xa')](function(_0x4b2947,_0x5da8a3){if(_0x4b2947){_0x415bc5[_0x55e0('0x4')](_0x55e0('0xb'),new AGIError(_0x55e0('0xc'),_0x4b2947));}else if(_0x7cb21a&&_0x7cb21a<0x0){_0x415bc5[_0x55e0('0x4')]('error',new AGIError('E_AGI_SERVER_VOICE_DISABLED'));_0x20efcb[_0x55e0('0xd')]();}else if(_0x7cb21a&&_0x7cb21a>0x0&&_0x7cb21a<_0x5da8a3){_0x32d216+=0x1;_0x415bc5[_0x55e0('0x4')](_0x55e0('0xb'),new AGIError(_0x55e0('0xe'),_0x32d216));_0x20efcb[_0x55e0('0xd')]();}else{var _0x24bd8f=new AGIChannel(_0x20efcb);_0x24bd8f['on'](_0x55e0('0xf'),function(){_0x415bc5['emit']('connection',_0x24bd8f);});}});});_0x496a50['on'](_0x55e0('0xb'),function(_0x7cd5d4){_0x415bc5['emit'](_0x55e0('0xb'),new AGIError(_0x55e0('0xc'),_0x7cd5d4[_0x55e0('0x10')]));});_0x496a50['on'](_0x55e0('0x11'),function(){_0x415bc5['emit'](_0x55e0('0x11'),new AGIError(_0x55e0('0x12')));});}process[_0x55e0('0x13')](function(){_0x2d6ebf();});};util[_0x55e0('0x14')](AGIServer,EventEmitter);module[_0x55e0('0x15')]=function(_0x54cdad,_0x518f26,_0x3ca67b){return new AGIServer(_0x54cdad,_0x518f26,_0x3ca67b);};