Built motion from commit (unavailable).|2.5.27
[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 _0xcc8d=['127.0.0.1','call','emit','E_AGI_ARGUMENT_PORT','createServer','listen','listening','connection','getConnections','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','destroy','error','code','close','exports','net','events','./channel'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xcc8d,0xbb));var _0xdcc8=function(_0x4b9dc9,_0x14b3a2){_0x4b9dc9=_0x4b9dc9-0x0;var _0x57b302=_0xcc8d[_0x4b9dc9];return _0x57b302;};'use strict';var util=require('util');var net=require(_0xdcc8('0x0'));var EventEmitter=require(_0xdcc8('0x1'))['EventEmitter'];var AGIError=require('./error');var AGIChannel=require(_0xdcc8('0x2'));var AGIServer=function(_0x412657,_0x32d674,_0x33ec37){var _0x350afb=this,_0x412657=_0x412657||0x11dd,_0x32d674=_0x32d674||_0xdcc8('0x3'),_0x47b30e=null,_0x44e0b0=0x0;EventEmitter[_0xdcc8('0x4')](_0x350afb);function _0x237528(){if(!_0x412657){_0x350afb[_0xdcc8('0x5')]('error',new AGIError(_0xdcc8('0x6')));return![];}_0x47b30e=net[_0xdcc8('0x7')]();_0x47b30e[_0xdcc8('0x8')](_0x412657,_0x32d674);_0x47b30e['on'](_0xdcc8('0x9'),function(){_0x350afb[_0xdcc8('0x5')](_0xdcc8('0x9'));});_0x47b30e['on'](_0xdcc8('0xa'),function(_0x1612ad){_0x47b30e[_0xdcc8('0xb')](function(_0x390f8c,_0x771c05){if(_0x390f8c){_0x350afb[_0xdcc8('0x5')]('error',new AGIError(_0xdcc8('0xc'),_0x390f8c));}else if(_0x33ec37&&_0x33ec37<0x0){_0x350afb[_0xdcc8('0x5')]('error',new AGIError(_0xdcc8('0xd')));_0x1612ad[_0xdcc8('0xe')]();}else if(_0x33ec37&&_0x33ec37>0x0&&_0x33ec37<_0x771c05){_0x44e0b0+=0x1;_0x350afb[_0xdcc8('0x5')](_0xdcc8('0xf'),new AGIError('E_AGI_SERVER_MAXCONNECTION',_0x44e0b0));_0x1612ad[_0xdcc8('0xe')]();}else{var _0x446b5c=new AGIChannel(_0x1612ad);_0x446b5c['on']('ready',function(){_0x350afb[_0xdcc8('0x5')]('connection',_0x446b5c);});}});});_0x47b30e['on'](_0xdcc8('0xf'),function(_0x3dfd45){_0x350afb[_0xdcc8('0x5')](_0xdcc8('0xf'),new AGIError(_0xdcc8('0xc'),_0x3dfd45[_0xdcc8('0x10')]));});_0x47b30e['on'](_0xdcc8('0x11'),function(){_0x350afb['emit']('close',new AGIError('E_AGI_SERVER_CLOSE'));});}process['nextTick'](function(){_0x237528();});};util['inherits'](AGIServer,EventEmitter);module[_0xdcc8('0x12')]=function(_0x4dff9b,_0xd07622,_0x249f47){return new AGIServer(_0x4dff9b,_0xd07622,_0x249f47);};