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 _0x05fc=['emit','E_AGI_ARGUMENT_PORT','createServer','listen','listening','getConnections','error','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','destroy','E_AGI_SERVER_MAXCONNECTION','connection','code','close','E_AGI_SERVER_CLOSE','nextTick','inherits','exports','net','EventEmitter','./error','./channel','127.0.0.1','call'];(function(_0xfd363,_0x13cb58){var _0x6ddc0e=function(_0x2164aa){while(--_0x2164aa){_0xfd363['push'](_0xfd363['shift']());}};_0x6ddc0e(++_0x13cb58);}(_0x05fc,0x102));var _0xc05f=function(_0xd1d19a,_0x1933f0){_0xd1d19a=_0xd1d19a-0x0;var _0x52a79d=_0x05fc[_0xd1d19a];return _0x52a79d;};'use strict';var util=require('util');var net=require(_0xc05f('0x0'));var EventEmitter=require('events')[_0xc05f('0x1')];var AGIError=require(_0xc05f('0x2'));var AGIChannel=require(_0xc05f('0x3'));var AGIServer=function(_0x378bd8,_0x10cd2f,_0x2d1892){var _0x149cbf=this,_0x378bd8=_0x378bd8||0x11dd,_0x10cd2f=_0x10cd2f||_0xc05f('0x4'),_0x26d12f=null,_0x59c001=0x0;EventEmitter[_0xc05f('0x5')](_0x149cbf);function _0x15ed7a(){if(!_0x378bd8){_0x149cbf[_0xc05f('0x6')]('error',new AGIError(_0xc05f('0x7')));return![];}_0x26d12f=net[_0xc05f('0x8')]();_0x26d12f[_0xc05f('0x9')](_0x378bd8,_0x10cd2f);_0x26d12f['on'](_0xc05f('0xa'),function(){_0x149cbf[_0xc05f('0x6')](_0xc05f('0xa'));});_0x26d12f['on']('connection',function(_0x2fded0){_0x26d12f[_0xc05f('0xb')](function(_0x59f6f4,_0xbce182){if(_0x59f6f4){_0x149cbf[_0xc05f('0x6')](_0xc05f('0xc'),new AGIError(_0xc05f('0xd'),_0x59f6f4));}else if(_0x2d1892&&_0x2d1892<0x0){_0x149cbf['emit'](_0xc05f('0xc'),new AGIError(_0xc05f('0xe')));_0x2fded0[_0xc05f('0xf')]();}else if(_0x2d1892&&_0x2d1892>0x0&&_0x2d1892<_0xbce182){_0x59c001+=0x1;_0x149cbf['emit'](_0xc05f('0xc'),new AGIError(_0xc05f('0x10'),_0x59c001));_0x2fded0[_0xc05f('0xf')]();}else{var _0x412ccd=new AGIChannel(_0x2fded0);_0x412ccd['on']('ready',function(){_0x149cbf[_0xc05f('0x6')](_0xc05f('0x11'),_0x412ccd);});}});});_0x26d12f['on'](_0xc05f('0xc'),function(_0x1eefc0){_0x149cbf[_0xc05f('0x6')](_0xc05f('0xc'),new AGIError(_0xc05f('0xd'),_0x1eefc0[_0xc05f('0x12')]));});_0x26d12f['on'](_0xc05f('0x13'),function(){_0x149cbf['emit'](_0xc05f('0x13'),new AGIError(_0xc05f('0x14')));});}process[_0xc05f('0x15')](function(){_0x15ed7a();});};util[_0xc05f('0x16')](AGIServer,EventEmitter);module[_0xc05f('0x17')]=function(_0x3100a4,_0x279498,_0x97ecfb){return new AGIServer(_0x3100a4,_0x279498,_0x97ecfb);};