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 _0xd0bb=['getConnections','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','destroy','E_AGI_SERVER_MAXCONNECTION','ready','close','E_AGI_SERVER_CLOSE','nextTick','inherits','exports','util','net','events','./error','127.0.0.1','call','emit','error','E_AGI_ARGUMENT_PORT','createServer','listen','listening','connection'];(function(_0x34121c,_0x229400){var _0x461cfc=function(_0x564eed){while(--_0x564eed){_0x34121c['push'](_0x34121c['shift']());}};_0x461cfc(++_0x229400);}(_0xd0bb,0x1eb));var _0xbd0b=function(_0x3ea343,_0x168e7e){_0x3ea343=_0x3ea343-0x0;var _0x1ae8e5=_0xd0bb[_0x3ea343];return _0x1ae8e5;};'use strict';var util=require(_0xbd0b('0x0'));var net=require(_0xbd0b('0x1'));var EventEmitter=require(_0xbd0b('0x2'))['EventEmitter'];var AGIError=require(_0xbd0b('0x3'));var AGIChannel=require('./channel');var AGIServer=function(_0x39b03a,_0x1f6ec3,_0x53e6ce){var _0x432acf=this,_0x39b03a=_0x39b03a||0x11dd,_0x1f6ec3=_0x1f6ec3||_0xbd0b('0x4'),_0x1b2499=null,_0x158b5c=0x0;EventEmitter[_0xbd0b('0x5')](_0x432acf);function _0x5eb975(){if(!_0x39b03a){_0x432acf[_0xbd0b('0x6')](_0xbd0b('0x7'),new AGIError(_0xbd0b('0x8')));return![];}_0x1b2499=net[_0xbd0b('0x9')]();_0x1b2499[_0xbd0b('0xa')](_0x39b03a,_0x1f6ec3);_0x1b2499['on']('listening',function(){_0x432acf['emit'](_0xbd0b('0xb'));});_0x1b2499['on'](_0xbd0b('0xc'),function(_0x4a69ff){_0x1b2499[_0xbd0b('0xd')](function(_0x196beb,_0x526258){if(_0x196beb){_0x432acf[_0xbd0b('0x6')](_0xbd0b('0x7'),new AGIError(_0xbd0b('0xe'),_0x196beb));}else if(_0x53e6ce&&_0x53e6ce<0x0){_0x432acf[_0xbd0b('0x6')](_0xbd0b('0x7'),new AGIError(_0xbd0b('0xf')));_0x4a69ff[_0xbd0b('0x10')]();}else if(_0x53e6ce&&_0x53e6ce>0x0&&_0x53e6ce<_0x526258){_0x158b5c+=0x1;_0x432acf[_0xbd0b('0x6')](_0xbd0b('0x7'),new AGIError(_0xbd0b('0x11'),_0x158b5c));_0x4a69ff[_0xbd0b('0x10')]();}else{var _0x57077a=new AGIChannel(_0x4a69ff);_0x57077a['on'](_0xbd0b('0x12'),function(){_0x432acf['emit']('connection',_0x57077a);});}});});_0x1b2499['on'](_0xbd0b('0x7'),function(_0x4c0e52){_0x432acf[_0xbd0b('0x6')](_0xbd0b('0x7'),new AGIError(_0xbd0b('0xe'),_0x4c0e52['code']));});_0x1b2499['on']('close',function(){_0x432acf[_0xbd0b('0x6')](_0xbd0b('0x13'),new AGIError(_0xbd0b('0x14')));});}process[_0xbd0b('0x15')](function(){_0x5eb975();});};util[_0xbd0b('0x16')](AGIServer,EventEmitter);module[_0xbd0b('0x17')]=function(_0x5aeb79,_0x1d1292,_0x49499f){return new AGIServer(_0x5aeb79,_0x1d1292,_0x49499f);};