f8b93f6c451414679db687ed140a30a5baab4cd8
[motion-next.git] / server / services / agi / server.js
1 const a1046_0x23c1=['E_AGI_SERVER_VOICE_DISABLED','destroy','close','./channel','E_AGI_SERVER_MAXCONNECTION','listening','emit','net','listen','error','exports','EventEmitter','E_AGI_ARGUMENT_PORT','util','ready','call','E_AGI_SERVER_ERROR','connection','createServer','getConnections','inherits'];(function(_0x2f1e06,_0x23c10c){const _0x1c6daf=function(_0x5cb26e){while(--_0x5cb26e){_0x2f1e06['push'](_0x2f1e06['shift']());}};_0x1c6daf(++_0x23c10c);}(a1046_0x23c1,0x199));const a1046_0x1c6d=function(_0x2f1e06,_0x23c10c){_0x2f1e06=_0x2f1e06-0x0;let _0x1c6daf=a1046_0x23c1[_0x2f1e06];return _0x1c6daf;};const _0x169247=a1046_0x1c6d;'use strict';const util=require(_0x169247('0x3')),net=require(_0x169247('0x12')),EventEmitter=require('events')[_0x169247('0x1')],AGIError=require('./error'),AGIChannel=require(_0x169247('0xe')),AGIServer=function(_0x5cb26e,_0x36d766,_0x334745){const _0x21f618=_0x169247,_0x21644e=this;_0x5cb26e=_0x5cb26e||0x11dd,_0x36d766=_0x36d766||'127.0.0.1';let _0x15d1e6=null,_0x50608d=0x0;EventEmitter[_0x21f618('0x5')](_0x21644e);function _0x20e75e(){const _0x5b0bdf=_0x21f618;if(!_0x5cb26e)return _0x21644e[_0x5b0bdf('0x11')]('error',new AGIError(_0x5b0bdf('0x2'))),![];_0x15d1e6=net[_0x5b0bdf('0x8')](),_0x15d1e6[_0x5b0bdf('0x13')](_0x5cb26e,_0x36d766),_0x15d1e6['on'](_0x5b0bdf('0x10'),function(){const _0x1a2c0f=_0x5b0bdf;_0x21644e[_0x1a2c0f('0x11')]('listening');}),_0x15d1e6['on'](_0x5b0bdf('0x7'),function(_0x4d8a2d){const _0x3f00f9=_0x5b0bdf;_0x15d1e6[_0x3f00f9('0x9')](function(_0x4cddec,_0x1fbc35){const _0x33007b=_0x3f00f9;if(_0x4cddec)_0x21644e[_0x33007b('0x11')]('error',new AGIError(_0x33007b('0x6'),_0x4cddec));else{if(_0x334745&&_0x334745<0x0)_0x21644e[_0x33007b('0x11')](_0x33007b('0x14'),new AGIError(_0x33007b('0xb'))),_0x4d8a2d[_0x33007b('0xc')]();else{if(_0x334745&&_0x334745>0x0&&_0x334745<_0x1fbc35)_0x50608d+=0x1,_0x21644e[_0x33007b('0x11')](_0x33007b('0x14'),new AGIError(_0x33007b('0xf'),_0x50608d)),_0x4d8a2d[_0x33007b('0xc')]();else{const _0x579373=new AGIChannel(_0x4d8a2d);_0x579373['on'](_0x33007b('0x4'),function(){const _0xa324e2=_0x33007b;_0x21644e[_0xa324e2('0x11')]('connection',_0x579373);});}}}});}),_0x15d1e6['on'](_0x5b0bdf('0x14'),function(_0x221c6a){const _0x8e1020=_0x5b0bdf;_0x21644e[_0x8e1020('0x11')]('error',new AGIError(_0x8e1020('0x6'),_0x221c6a['code']));}),_0x15d1e6['on'](_0x5b0bdf('0xd'),function(){const _0x490513=_0x5b0bdf;_0x21644e[_0x490513('0x11')]('close',new AGIError('E_AGI_SERVER_CLOSE'));});}process['nextTick'](function(){_0x20e75e();});};util[_0x169247('0xa')](AGIServer,EventEmitter),module[_0x169247('0x0')]=function(_0x169cd6,_0x52cdaf,_0x4c88e5){return new AGIServer(_0x169cd6,_0x52cdaf,_0x4c88e5);};