Built motion from commit 25580385.|2.6.2
[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 _0x82ae=['listening','emit','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','E_AGI_SERVER_MAXCONNECTION','destroy','ready','connection','code','close','E_AGI_SERVER_CLOSE','nextTick','inherits','exports','util','net','events','EventEmitter','./error','127.0.0.1','error','createServer'];(function(_0x3eed36,_0x2611ba){var _0xf90070=function(_0x192047){while(--_0x192047){_0x3eed36['push'](_0x3eed36['shift']());}};_0xf90070(++_0x2611ba);}(_0x82ae,0x92));var _0xe82a=function(_0x4b673d,_0x387dc6){_0x4b673d=_0x4b673d-0x0;var _0x175654=_0x82ae[_0x4b673d];return _0x175654;};'use strict';var util=require(_0xe82a('0x0'));var net=require(_0xe82a('0x1'));var EventEmitter=require(_0xe82a('0x2'))[_0xe82a('0x3')];var AGIError=require(_0xe82a('0x4'));var AGIChannel=require('./channel');var AGIServer=function(_0x5ec1c6,_0x173bac,_0x11533a){var _0x399972=this,_0x5ec1c6=_0x5ec1c6||0x11dd,_0x173bac=_0x173bac||_0xe82a('0x5'),_0x59e588=null,_0x51a7dc=0x0;EventEmitter['call'](_0x399972);function _0x429002(){if(!_0x5ec1c6){_0x399972['emit'](_0xe82a('0x6'),new AGIError('E_AGI_ARGUMENT_PORT'));return![];}_0x59e588=net[_0xe82a('0x7')]();_0x59e588['listen'](_0x5ec1c6,_0x173bac);_0x59e588['on'](_0xe82a('0x8'),function(){_0x399972[_0xe82a('0x9')]('listening');});_0x59e588['on']('connection',function(_0x2117c3){_0x59e588['getConnections'](function(_0x3fb404,_0xb08ee0){if(_0x3fb404){_0x399972[_0xe82a('0x9')](_0xe82a('0x6'),new AGIError(_0xe82a('0xa'),_0x3fb404));}else if(_0x11533a&&_0x11533a<0x0){_0x399972[_0xe82a('0x9')](_0xe82a('0x6'),new AGIError(_0xe82a('0xb')));_0x2117c3['destroy']();}else if(_0x11533a&&_0x11533a>0x0&&_0x11533a<_0xb08ee0){_0x51a7dc+=0x1;_0x399972[_0xe82a('0x9')](_0xe82a('0x6'),new AGIError(_0xe82a('0xc'),_0x51a7dc));_0x2117c3[_0xe82a('0xd')]();}else{var _0x31fee6=new AGIChannel(_0x2117c3);_0x31fee6['on'](_0xe82a('0xe'),function(){_0x399972[_0xe82a('0x9')](_0xe82a('0xf'),_0x31fee6);});}});});_0x59e588['on']('error',function(_0x522d8d){_0x399972[_0xe82a('0x9')]('error',new AGIError('E_AGI_SERVER_ERROR',_0x522d8d[_0xe82a('0x10')]));});_0x59e588['on'](_0xe82a('0x11'),function(){_0x399972[_0xe82a('0x9')](_0xe82a('0x11'),new AGIError(_0xe82a('0x12')));});}process[_0xe82a('0x13')](function(){_0x429002();});};util[_0xe82a('0x14')](AGIServer,EventEmitter);module[_0xe82a('0x15')]=function(_0x4dc8b3,_0x47fc06,_0x1814bb){return new AGIServer(_0x4dc8b3,_0x47fc06,_0x1814bb);};