Built motion from commit 092f8824.|2.5.49
[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 _0x632f=['127.0.0.1','call','E_AGI_ARGUMENT_PORT','createServer','listen','listening','emit','connection','getConnections','error','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','E_AGI_SERVER_MAXCONNECTION','code','close','E_AGI_SERVER_CLOSE','exports','util','net','events','EventEmitter','./error','./channel'];(function(_0x2f1123,_0x4204a0){var _0x4f98e0=function(_0x24b63d){while(--_0x24b63d){_0x2f1123['push'](_0x2f1123['shift']());}};_0x4f98e0(++_0x4204a0);}(_0x632f,0x1f4));var _0xf632=function(_0x16d10f,_0x2ba2d5){_0x16d10f=_0x16d10f-0x0;var _0x50c823=_0x632f[_0x16d10f];return _0x50c823;};'use strict';var util=require(_0xf632('0x0'));var net=require(_0xf632('0x1'));var EventEmitter=require(_0xf632('0x2'))[_0xf632('0x3')];var AGIError=require(_0xf632('0x4'));var AGIChannel=require(_0xf632('0x5'));var AGIServer=function(_0x345043,_0x19b712,_0x175286){var _0x437e4d=this,_0x345043=_0x345043||0x11dd,_0x19b712=_0x19b712||_0xf632('0x6'),_0xfdf18d=null,_0x266159=0x0;EventEmitter[_0xf632('0x7')](_0x437e4d);function _0x4e9ba7(){if(!_0x345043){_0x437e4d['emit']('error',new AGIError(_0xf632('0x8')));return![];}_0xfdf18d=net[_0xf632('0x9')]();_0xfdf18d[_0xf632('0xa')](_0x345043,_0x19b712);_0xfdf18d['on'](_0xf632('0xb'),function(){_0x437e4d[_0xf632('0xc')](_0xf632('0xb'));});_0xfdf18d['on'](_0xf632('0xd'),function(_0x55684e){_0xfdf18d[_0xf632('0xe')](function(_0xbf92c7,_0x45dd49){if(_0xbf92c7){_0x437e4d['emit'](_0xf632('0xf'),new AGIError(_0xf632('0x10'),_0xbf92c7));}else if(_0x175286&&_0x175286<0x0){_0x437e4d[_0xf632('0xc')](_0xf632('0xf'),new AGIError(_0xf632('0x11')));_0x55684e['destroy']();}else if(_0x175286&&_0x175286>0x0&&_0x175286<_0x45dd49){_0x266159+=0x1;_0x437e4d[_0xf632('0xc')](_0xf632('0xf'),new AGIError(_0xf632('0x12'),_0x266159));_0x55684e['destroy']();}else{var _0x3eb75b=new AGIChannel(_0x55684e);_0x3eb75b['on']('ready',function(){_0x437e4d[_0xf632('0xc')]('connection',_0x3eb75b);});}});});_0xfdf18d['on']('error',function(_0x5a2d62){_0x437e4d['emit'](_0xf632('0xf'),new AGIError(_0xf632('0x10'),_0x5a2d62[_0xf632('0x13')]));});_0xfdf18d['on'](_0xf632('0x14'),function(){_0x437e4d[_0xf632('0xc')](_0xf632('0x14'),new AGIError(_0xf632('0x15')));});}process['nextTick'](function(){_0x4e9ba7();});};util['inherits'](AGIServer,EventEmitter);module[_0xf632('0x16')]=function(_0x253e03,_0x26aa78,_0x358864){return new AGIServer(_0x253e03,_0x26aa78,_0x358864);};