4ed1e154f096f8d024029fc0b45fd3766377562b
[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 _0xfa91=['inherits','util','net','events','./error','call','emit','E_AGI_ARGUMENT_PORT','createServer','listen','listening','connection','getConnections','error','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','E_AGI_SERVER_MAXCONNECTION','destroy','code','close','E_AGI_SERVER_CLOSE'];(function(_0x2cfd6c,_0x2c1aeb){var _0x4d367a=function(_0x1944f4){while(--_0x1944f4){_0x2cfd6c['push'](_0x2cfd6c['shift']());}};_0x4d367a(++_0x2c1aeb);}(_0xfa91,0x151));var _0x1fa9=function(_0x474bc0,_0x26989c){_0x474bc0=_0x474bc0-0x0;var _0x4b24cf=_0xfa91[_0x474bc0];return _0x4b24cf;};'use strict';var util=require(_0x1fa9('0x0'));var net=require(_0x1fa9('0x1'));var EventEmitter=require(_0x1fa9('0x2'))['EventEmitter'];var AGIError=require(_0x1fa9('0x3'));var AGIChannel=require('./channel');var AGIServer=function(_0x54ea96,_0x32efc9,_0x1784f6){var _0x29e527=this,_0x54ea96=_0x54ea96||0x11dd,_0x32efc9=_0x32efc9||'127.0.0.1',_0x27679c=null,_0x37e3f6=0x0;EventEmitter[_0x1fa9('0x4')](_0x29e527);function _0x538ba7(){if(!_0x54ea96){_0x29e527[_0x1fa9('0x5')]('error',new AGIError(_0x1fa9('0x6')));return![];}_0x27679c=net[_0x1fa9('0x7')]();_0x27679c[_0x1fa9('0x8')](_0x54ea96,_0x32efc9);_0x27679c['on'](_0x1fa9('0x9'),function(){_0x29e527['emit'](_0x1fa9('0x9'));});_0x27679c['on'](_0x1fa9('0xa'),function(_0x343d23){_0x27679c[_0x1fa9('0xb')](function(_0x3d80b5,_0x70898b){if(_0x3d80b5){_0x29e527[_0x1fa9('0x5')](_0x1fa9('0xc'),new AGIError(_0x1fa9('0xd'),_0x3d80b5));}else if(_0x1784f6&&_0x1784f6<0x0){_0x29e527[_0x1fa9('0x5')](_0x1fa9('0xc'),new AGIError(_0x1fa9('0xe')));_0x343d23['destroy']();}else if(_0x1784f6&&_0x1784f6>0x0&&_0x1784f6<_0x70898b){_0x37e3f6+=0x1;_0x29e527[_0x1fa9('0x5')](_0x1fa9('0xc'),new AGIError(_0x1fa9('0xf'),_0x37e3f6));_0x343d23[_0x1fa9('0x10')]();}else{var _0x5b49e3=new AGIChannel(_0x343d23);_0x5b49e3['on']('ready',function(){_0x29e527['emit'](_0x1fa9('0xa'),_0x5b49e3);});}});});_0x27679c['on'](_0x1fa9('0xc'),function(_0x5a26){_0x29e527['emit'](_0x1fa9('0xc'),new AGIError(_0x1fa9('0xd'),_0x5a26[_0x1fa9('0x11')]));});_0x27679c['on']('close',function(){_0x29e527[_0x1fa9('0x5')](_0x1fa9('0x12'),new AGIError(_0x1fa9('0x13')));});}process['nextTick'](function(){_0x538ba7();});};util[_0x1fa9('0x14')](AGIServer,EventEmitter);module['exports']=function(_0xe28e45,_0xd5a8c5,_0x4fb336){return new AGIServer(_0xe28e45,_0xd5a8c5,_0x4fb336);};