Built motion from commit (unavailable).|2.5.7
[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 _0x7ee1=['127.0.0.1','call','emit','E_AGI_ARGUMENT_PORT','createServer','listening','connection','getConnections','error','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','destroy','ready','code','close','E_AGI_SERVER_CLOSE','nextTick','util','events','EventEmitter','./error','./channel'];(function(_0x529955,_0x491695){var _0x3989ff=function(_0x511f3f){while(--_0x511f3f){_0x529955['push'](_0x529955['shift']());}};_0x3989ff(++_0x491695);}(_0x7ee1,0xab));var _0x17ee=function(_0xefed20,_0x165d70){_0xefed20=_0xefed20-0x0;var _0xe6361a=_0x7ee1[_0xefed20];return _0xe6361a;};'use strict';var util=require(_0x17ee('0x0'));var net=require('net');var EventEmitter=require(_0x17ee('0x1'))[_0x17ee('0x2')];var AGIError=require(_0x17ee('0x3'));var AGIChannel=require(_0x17ee('0x4'));var AGIServer=function(_0x45c9e3,_0x48baa3,_0x3a5743){var _0x5172f0=this,_0x45c9e3=_0x45c9e3||0x11dd,_0x48baa3=_0x48baa3||_0x17ee('0x5'),_0x2e4db0=null,_0x2efefb=0x0;EventEmitter[_0x17ee('0x6')](_0x5172f0);function _0x59b876(){if(!_0x45c9e3){_0x5172f0[_0x17ee('0x7')]('error',new AGIError(_0x17ee('0x8')));return![];}_0x2e4db0=net[_0x17ee('0x9')]();_0x2e4db0['listen'](_0x45c9e3,_0x48baa3);_0x2e4db0['on'](_0x17ee('0xa'),function(){_0x5172f0[_0x17ee('0x7')](_0x17ee('0xa'));});_0x2e4db0['on'](_0x17ee('0xb'),function(_0x3ac76a){_0x2e4db0[_0x17ee('0xc')](function(_0xac3906,_0xcb2375){if(_0xac3906){_0x5172f0[_0x17ee('0x7')](_0x17ee('0xd'),new AGIError(_0x17ee('0xe'),_0xac3906));}else if(_0x3a5743&&_0x3a5743<0x0){_0x5172f0[_0x17ee('0x7')]('error',new AGIError(_0x17ee('0xf')));_0x3ac76a[_0x17ee('0x10')]();}else if(_0x3a5743&&_0x3a5743>0x0&&_0x3a5743<_0xcb2375){_0x2efefb+=0x1;_0x5172f0['emit'](_0x17ee('0xd'),new AGIError('E_AGI_SERVER_MAXCONNECTION',_0x2efefb));_0x3ac76a[_0x17ee('0x10')]();}else{var _0x27447d=new AGIChannel(_0x3ac76a);_0x27447d['on'](_0x17ee('0x11'),function(){_0x5172f0[_0x17ee('0x7')]('connection',_0x27447d);});}});});_0x2e4db0['on'](_0x17ee('0xd'),function(_0x749078){_0x5172f0[_0x17ee('0x7')]('error',new AGIError(_0x17ee('0xe'),_0x749078[_0x17ee('0x12')]));});_0x2e4db0['on'](_0x17ee('0x13'),function(){_0x5172f0[_0x17ee('0x7')](_0x17ee('0x13'),new AGIError(_0x17ee('0x14')));});}process[_0x17ee('0x15')](function(){_0x59b876();});};util['inherits'](AGIServer,EventEmitter);module['exports']=function(_0x24d546,_0x17693e,_0x1f8fb){return new AGIServer(_0x24d546,_0x17693e,_0x1f8fb);};