Built motion from commit (unavailable).|2.5.4
[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 _0x98e1=['listen','listening','connection','getConnections','E_AGI_SERVER_ERROR','error','E_AGI_SERVER_MAXCONNECTION','destroy','close','E_AGI_SERVER_CLOSE','nextTick','inherits','net','events','EventEmitter','./error','call','emit','E_AGI_ARGUMENT_PORT','createServer'];(function(_0x21a9d9,_0x4d5ac8){var _0x46adce=function(_0xfdd336){while(--_0xfdd336){_0x21a9d9['push'](_0x21a9d9['shift']());}};_0x46adce(++_0x4d5ac8);}(_0x98e1,0x160));var _0x198e=function(_0x5b1bbc,_0x98e6c3){_0x5b1bbc=_0x5b1bbc-0x0;var _0x424fb4=_0x98e1[_0x5b1bbc];return _0x424fb4;};'use strict';var util=require('util');var net=require(_0x198e('0x0'));var EventEmitter=require(_0x198e('0x1'))[_0x198e('0x2')];var AGIError=require(_0x198e('0x3'));var AGIChannel=require('./channel');var AGIServer=function(_0x300c4b,_0x4e997a,_0x4a102f){var _0x3bd989=this,_0x300c4b=_0x300c4b||0x11dd,_0x4e997a=_0x4e997a||'127.0.0.1',_0x317209=null,_0x551d31=0x0;EventEmitter[_0x198e('0x4')](_0x3bd989);function _0x4d45d6(){if(!_0x300c4b){_0x3bd989[_0x198e('0x5')]('error',new AGIError(_0x198e('0x6')));return![];}_0x317209=net[_0x198e('0x7')]();_0x317209[_0x198e('0x8')](_0x300c4b,_0x4e997a);_0x317209['on'](_0x198e('0x9'),function(){_0x3bd989[_0x198e('0x5')](_0x198e('0x9'));});_0x317209['on'](_0x198e('0xa'),function(_0x162604){_0x317209[_0x198e('0xb')](function(_0x5be755,_0x33e0a5){if(_0x5be755){_0x3bd989[_0x198e('0x5')]('error',new AGIError(_0x198e('0xc'),_0x5be755));}else if(_0x4a102f&&_0x4a102f<0x0){_0x3bd989['emit'](_0x198e('0xd'),new AGIError('E_AGI_SERVER_VOICE_DISABLED'));_0x162604['destroy']();}else if(_0x4a102f&&_0x4a102f>0x0&&_0x4a102f<_0x33e0a5){_0x551d31+=0x1;_0x3bd989['emit']('error',new AGIError(_0x198e('0xe'),_0x551d31));_0x162604[_0x198e('0xf')]();}else{var _0x10d24e=new AGIChannel(_0x162604);_0x10d24e['on']('ready',function(){_0x3bd989[_0x198e('0x5')](_0x198e('0xa'),_0x10d24e);});}});});_0x317209['on'](_0x198e('0xd'),function(_0x5035de){_0x3bd989['emit']('error',new AGIError('E_AGI_SERVER_ERROR',_0x5035de['code']));});_0x317209['on'](_0x198e('0x10'),function(){_0x3bd989['emit']('close',new AGIError(_0x198e('0x11')));});}process[_0x198e('0x12')](function(){_0x4d45d6();});};util[_0x198e('0x13')](AGIServer,EventEmitter);module['exports']=function(_0x7742f1,_0x3679aa,_0x2fdc34){return new AGIServer(_0x7742f1,_0x3679aa,_0x2fdc34);};