Built motion from commit 67e5df37.|2.0.68
[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 _0x2bde=['exports','util','./error','./channel','0.0.0.0','call','emit','error','E_AGI_ARGUMENT_PORT','createServer','listen','listening','connection','E_AGI_SERVER_MAXCONNECTION','E_AGI_SERVER_ERROR','code','close','E_AGI_SERVER_CLOSE','nextTick','inherits'];(function(_0x20e9d5,_0x67b7b3){var _0x5e1154=function(_0x1b08e2){while(--_0x1b08e2){_0x20e9d5['push'](_0x20e9d5['shift']());}};_0x5e1154(++_0x67b7b3);}(_0x2bde,0x169));var _0xe2bd=function(_0x5b64a1,_0x2ec810){_0x5b64a1=_0x5b64a1-0x0;var _0x4b6f55=_0x2bde[_0x5b64a1];return _0x4b6f55;};'use strict';var util=require(_0xe2bd('0x0'));var net=require('net');var EventEmitter=require('events')['EventEmitter'];var AGIError=require(_0xe2bd('0x1'));var AGIChannel=require(_0xe2bd('0x2'));var AGIServer=function(_0x3dc660,_0x339af4,_0xb71f14){var _0x33719f=this,_0x3dc660=_0x3dc660||0x11dd,_0x339af4=_0x339af4||_0xe2bd('0x3'),_0x8c57f0=null,_0x13861a=0x0;EventEmitter[_0xe2bd('0x4')](_0x33719f);function _0x1265c7(){if(!_0x3dc660){_0x33719f[_0xe2bd('0x5')](_0xe2bd('0x6'),new AGIError(_0xe2bd('0x7')));return![];}_0x8c57f0=net[_0xe2bd('0x8')]();_0x8c57f0[_0xe2bd('0x9')](_0x3dc660,_0x339af4);_0x8c57f0['on'](_0xe2bd('0xa'),function(){_0x33719f[_0xe2bd('0x5')](_0xe2bd('0xa'));});_0x8c57f0['on'](_0xe2bd('0xb'),function(_0x15be9c){_0x8c57f0['getConnections'](function(_0x30a763,_0x289a53){if(_0x30a763){_0x33719f['emit'](_0xe2bd('0x6'),new AGIError('E_AGI_SERVER_ERROR',_0x30a763));}else if(_0xb71f14&&_0xb71f14>0x0&&_0xb71f14<_0x289a53){_0x13861a+=0x1;_0x33719f[_0xe2bd('0x5')](_0xe2bd('0x6'),new AGIError(_0xe2bd('0xc'),_0x13861a));_0x15be9c['destroy']();}else{var _0x276aec=new AGIChannel(_0x15be9c);_0x276aec['on']('ready',function(){_0x33719f[_0xe2bd('0x5')]('connection',_0x276aec);});}});});_0x8c57f0['on']('error',function(_0x2c2fa6){_0x33719f[_0xe2bd('0x5')](_0xe2bd('0x6'),new AGIError(_0xe2bd('0xd'),_0x2c2fa6[_0xe2bd('0xe')]));});_0x8c57f0['on'](_0xe2bd('0xf'),function(){_0x33719f[_0xe2bd('0x5')](_0xe2bd('0xf'),new AGIError(_0xe2bd('0x10')));});}process[_0xe2bd('0x11')](function(){_0x1265c7();});};util[_0xe2bd('0x12')](AGIServer,EventEmitter);module[_0xe2bd('0x13')]=function(_0x1d3f5a,_0x4c33cd,_0x2e0397){return new AGIServer(_0x1d3f5a,_0x4c33cd,_0x2e0397);};