Built motion from commit 43538d75.|2.5.35
[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 _0x78a5=['E_AGI_SERVER_VOICE_DISABLED','destroy','E_AGI_SERVER_MAXCONNECTION','ready','code','close','E_AGI_SERVER_CLOSE','nextTick','inherits','exports','util','events','EventEmitter','./error','./channel','127.0.0.1','call','emit','error','E_AGI_ARGUMENT_PORT','createServer','listen','listening','connection','E_AGI_SERVER_ERROR'];(function(_0x3ad960,_0x139261){var _0x44ef41=function(_0x3e3aaf){while(--_0x3e3aaf){_0x3ad960['push'](_0x3ad960['shift']());}};_0x44ef41(++_0x139261);}(_0x78a5,0xeb));var _0x578a=function(_0x1da527,_0x2dc953){_0x1da527=_0x1da527-0x0;var _0x40fc7c=_0x78a5[_0x1da527];return _0x40fc7c;};'use strict';var util=require(_0x578a('0x0'));var net=require('net');var EventEmitter=require(_0x578a('0x1'))[_0x578a('0x2')];var AGIError=require(_0x578a('0x3'));var AGIChannel=require(_0x578a('0x4'));var AGIServer=function(_0x25ead5,_0x37c0f9,_0x5b3df8){var _0x1c0d06=this,_0x25ead5=_0x25ead5||0x11dd,_0x37c0f9=_0x37c0f9||_0x578a('0x5'),_0x1d6396=null,_0x2a9d9f=0x0;EventEmitter[_0x578a('0x6')](_0x1c0d06);function _0x2a3426(){if(!_0x25ead5){_0x1c0d06[_0x578a('0x7')](_0x578a('0x8'),new AGIError(_0x578a('0x9')));return![];}_0x1d6396=net[_0x578a('0xa')]();_0x1d6396[_0x578a('0xb')](_0x25ead5,_0x37c0f9);_0x1d6396['on'](_0x578a('0xc'),function(){_0x1c0d06[_0x578a('0x7')](_0x578a('0xc'));});_0x1d6396['on'](_0x578a('0xd'),function(_0xb473f4){_0x1d6396['getConnections'](function(_0x2571a6,_0x48e0b2){if(_0x2571a6){_0x1c0d06[_0x578a('0x7')](_0x578a('0x8'),new AGIError(_0x578a('0xe'),_0x2571a6));}else if(_0x5b3df8&&_0x5b3df8<0x0){_0x1c0d06[_0x578a('0x7')](_0x578a('0x8'),new AGIError(_0x578a('0xf')));_0xb473f4[_0x578a('0x10')]();}else if(_0x5b3df8&&_0x5b3df8>0x0&&_0x5b3df8<_0x48e0b2){_0x2a9d9f+=0x1;_0x1c0d06[_0x578a('0x7')](_0x578a('0x8'),new AGIError(_0x578a('0x11'),_0x2a9d9f));_0xb473f4[_0x578a('0x10')]();}else{var _0x3b7b6f=new AGIChannel(_0xb473f4);_0x3b7b6f['on'](_0x578a('0x12'),function(){_0x1c0d06[_0x578a('0x7')](_0x578a('0xd'),_0x3b7b6f);});}});});_0x1d6396['on'](_0x578a('0x8'),function(_0x2f3fdb){_0x1c0d06[_0x578a('0x7')](_0x578a('0x8'),new AGIError(_0x578a('0xe'),_0x2f3fdb[_0x578a('0x13')]));});_0x1d6396['on'](_0x578a('0x14'),function(){_0x1c0d06[_0x578a('0x7')](_0x578a('0x14'),new AGIError(_0x578a('0x15')));});}process[_0x578a('0x16')](function(){_0x2a3426();});};util[_0x578a('0x17')](AGIServer,EventEmitter);module[_0x578a('0x18')]=function(_0x4a72a0,_0x452450,_0x5692ab){return new AGIServer(_0x4a72a0,_0x452450,_0x5692ab);};