Built motion from commit (unavailable).|2.5.28
[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 _0x4ded=['E_AGI_SERVER_MAXCONNECTION','ready','code','close','inherits','util','net','events','EventEmitter','./error','./channel','127.0.0.1','call','emit','error','createServer','listening','connection','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','destroy'];(function(_0x450689,_0x3b857c){var _0x46ffb0=function(_0x5d3679){while(--_0x5d3679){_0x450689['push'](_0x450689['shift']());}};_0x46ffb0(++_0x3b857c);}(_0x4ded,0x116));var _0xd4de=function(_0x29c7b3,_0xf647f0){_0x29c7b3=_0x29c7b3-0x0;var _0x112b4f=_0x4ded[_0x29c7b3];return _0x112b4f;};'use strict';var util=require(_0xd4de('0x0'));var net=require(_0xd4de('0x1'));var EventEmitter=require(_0xd4de('0x2'))[_0xd4de('0x3')];var AGIError=require(_0xd4de('0x4'));var AGIChannel=require(_0xd4de('0x5'));var AGIServer=function(_0x1b2252,_0x42f90f,_0x20930f){var _0x36d4dd=this,_0x1b2252=_0x1b2252||0x11dd,_0x42f90f=_0x42f90f||_0xd4de('0x6'),_0x554a51=null,_0x23e5b9=0x0;EventEmitter[_0xd4de('0x7')](_0x36d4dd);function _0x2c56d5(){if(!_0x1b2252){_0x36d4dd[_0xd4de('0x8')](_0xd4de('0x9'),new AGIError('E_AGI_ARGUMENT_PORT'));return![];}_0x554a51=net[_0xd4de('0xa')]();_0x554a51['listen'](_0x1b2252,_0x42f90f);_0x554a51['on']('listening',function(){_0x36d4dd['emit'](_0xd4de('0xb'));});_0x554a51['on'](_0xd4de('0xc'),function(_0x4e5b10){_0x554a51['getConnections'](function(_0x4c9499,_0x29e265){if(_0x4c9499){_0x36d4dd['emit'](_0xd4de('0x9'),new AGIError(_0xd4de('0xd'),_0x4c9499));}else if(_0x20930f&&_0x20930f<0x0){_0x36d4dd[_0xd4de('0x8')](_0xd4de('0x9'),new AGIError(_0xd4de('0xe')));_0x4e5b10[_0xd4de('0xf')]();}else if(_0x20930f&&_0x20930f>0x0&&_0x20930f<_0x29e265){_0x23e5b9+=0x1;_0x36d4dd[_0xd4de('0x8')](_0xd4de('0x9'),new AGIError(_0xd4de('0x10'),_0x23e5b9));_0x4e5b10[_0xd4de('0xf')]();}else{var _0x691ba9=new AGIChannel(_0x4e5b10);_0x691ba9['on'](_0xd4de('0x11'),function(){_0x36d4dd[_0xd4de('0x8')](_0xd4de('0xc'),_0x691ba9);});}});});_0x554a51['on'](_0xd4de('0x9'),function(_0xa7c18b){_0x36d4dd[_0xd4de('0x8')]('error',new AGIError('E_AGI_SERVER_ERROR',_0xa7c18b[_0xd4de('0x12')]));});_0x554a51['on'](_0xd4de('0x13'),function(){_0x36d4dd[_0xd4de('0x8')](_0xd4de('0x13'),new AGIError('E_AGI_SERVER_CLOSE'));});}process['nextTick'](function(){_0x2c56d5();});};util[_0xd4de('0x14')](AGIServer,EventEmitter);module['exports']=function(_0xeaaefa,_0x29c028,_0x50b9e3){return new AGIServer(_0xeaaefa,_0x29c028,_0x50b9e3);};