Built motion from commit 9d5c653a.|2.5.44
[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 _0x67d4=['exports','util','net','EventEmitter','./error','./channel','127.0.0.1','call','emit','error','createServer','listening','connection','getConnections','E_AGI_SERVER_VOICE_DISABLED','destroy','E_AGI_SERVER_MAXCONNECTION','ready','E_AGI_SERVER_ERROR','code','close','E_AGI_SERVER_CLOSE','nextTick','inherits'];(function(_0x1db1c3,_0x295a91){var _0x4a1284=function(_0x19388c){while(--_0x19388c){_0x1db1c3['push'](_0x1db1c3['shift']());}};_0x4a1284(++_0x295a91);}(_0x67d4,0x151));var _0x467d=function(_0x25e5e0,_0x254be1){_0x25e5e0=_0x25e5e0-0x0;var _0x3705f5=_0x67d4[_0x25e5e0];return _0x3705f5;};'use strict';var util=require(_0x467d('0x0'));var net=require(_0x467d('0x1'));var EventEmitter=require('events')[_0x467d('0x2')];var AGIError=require(_0x467d('0x3'));var AGIChannel=require(_0x467d('0x4'));var AGIServer=function(_0x377e82,_0x264f58,_0x342691){var _0x37b35c=this,_0x377e82=_0x377e82||0x11dd,_0x264f58=_0x264f58||_0x467d('0x5'),_0xbac768=null,_0x1dd77a=0x0;EventEmitter[_0x467d('0x6')](_0x37b35c);function _0x39850a(){if(!_0x377e82){_0x37b35c[_0x467d('0x7')](_0x467d('0x8'),new AGIError('E_AGI_ARGUMENT_PORT'));return![];}_0xbac768=net[_0x467d('0x9')]();_0xbac768['listen'](_0x377e82,_0x264f58);_0xbac768['on'](_0x467d('0xa'),function(){_0x37b35c[_0x467d('0x7')](_0x467d('0xa'));});_0xbac768['on'](_0x467d('0xb'),function(_0x3bde73){_0xbac768[_0x467d('0xc')](function(_0x1579b0,_0x5d34ea){if(_0x1579b0){_0x37b35c[_0x467d('0x7')](_0x467d('0x8'),new AGIError('E_AGI_SERVER_ERROR',_0x1579b0));}else if(_0x342691&&_0x342691<0x0){_0x37b35c[_0x467d('0x7')](_0x467d('0x8'),new AGIError(_0x467d('0xd')));_0x3bde73[_0x467d('0xe')]();}else if(_0x342691&&_0x342691>0x0&&_0x342691<_0x5d34ea){_0x1dd77a+=0x1;_0x37b35c[_0x467d('0x7')](_0x467d('0x8'),new AGIError(_0x467d('0xf'),_0x1dd77a));_0x3bde73[_0x467d('0xe')]();}else{var _0x134aa0=new AGIChannel(_0x3bde73);_0x134aa0['on'](_0x467d('0x10'),function(){_0x37b35c[_0x467d('0x7')]('connection',_0x134aa0);});}});});_0xbac768['on'](_0x467d('0x8'),function(_0x526851){_0x37b35c[_0x467d('0x7')](_0x467d('0x8'),new AGIError(_0x467d('0x11'),_0x526851[_0x467d('0x12')]));});_0xbac768['on'](_0x467d('0x13'),function(){_0x37b35c[_0x467d('0x7')]('close',new AGIError(_0x467d('0x14')));});}process[_0x467d('0x15')](function(){_0x39850a();});};util[_0x467d('0x16')](AGIServer,EventEmitter);module[_0x467d('0x17')]=function(_0xbeb50a,_0x5bcf53,_0x175b05){return new AGIServer(_0xbeb50a,_0x5bcf53,_0x175b05);};