2410712921f30d9bf0a0a7e32f4af2e8cb916a30
[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 _0x1a97=['ready','code','close','E_AGI_SERVER_CLOSE','inherits','exports','net','events','./error','./channel','127.0.0.1','call','emit','error','E_AGI_ARGUMENT_PORT','createServer','listen','listening','connection','getConnections','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','E_AGI_SERVER_MAXCONNECTION','destroy'];(function(_0x2154e7,_0x195446){var _0x462859=function(_0x295899){while(--_0x295899){_0x2154e7['push'](_0x2154e7['shift']());}};_0x462859(++_0x195446);}(_0x1a97,0x13e));var _0x71a9=function(_0x4c1ec2,_0x4f42b7){_0x4c1ec2=_0x4c1ec2-0x0;var _0x3f6f1c=_0x1a97[_0x4c1ec2];return _0x3f6f1c;};'use strict';var util=require('util');var net=require(_0x71a9('0x0'));var EventEmitter=require(_0x71a9('0x1'))['EventEmitter'];var AGIError=require(_0x71a9('0x2'));var AGIChannel=require(_0x71a9('0x3'));var AGIServer=function(_0x899f0f,_0x262121,_0x4e271a){var _0x10fd72=this,_0x899f0f=_0x899f0f||0x11dd,_0x262121=_0x262121||_0x71a9('0x4'),_0x1875a0=null,_0x4e0596=0x0;EventEmitter[_0x71a9('0x5')](_0x10fd72);function _0x35897a(){if(!_0x899f0f){_0x10fd72[_0x71a9('0x6')](_0x71a9('0x7'),new AGIError(_0x71a9('0x8')));return![];}_0x1875a0=net[_0x71a9('0x9')]();_0x1875a0[_0x71a9('0xa')](_0x899f0f,_0x262121);_0x1875a0['on'](_0x71a9('0xb'),function(){_0x10fd72[_0x71a9('0x6')]('listening');});_0x1875a0['on'](_0x71a9('0xc'),function(_0x5c9142){_0x1875a0[_0x71a9('0xd')](function(_0x322c79,_0x473ed7){if(_0x322c79){_0x10fd72['emit'](_0x71a9('0x7'),new AGIError(_0x71a9('0xe'),_0x322c79));}else if(_0x4e271a&&_0x4e271a<0x0){_0x10fd72[_0x71a9('0x6')](_0x71a9('0x7'),new AGIError(_0x71a9('0xf')));_0x5c9142['destroy']();}else if(_0x4e271a&&_0x4e271a>0x0&&_0x4e271a<_0x473ed7){_0x4e0596+=0x1;_0x10fd72[_0x71a9('0x6')]('error',new AGIError(_0x71a9('0x10'),_0x4e0596));_0x5c9142[_0x71a9('0x11')]();}else{var _0x4e6cb1=new AGIChannel(_0x5c9142);_0x4e6cb1['on'](_0x71a9('0x12'),function(){_0x10fd72['emit'](_0x71a9('0xc'),_0x4e6cb1);});}});});_0x1875a0['on']('error',function(_0x172e98){_0x10fd72['emit'](_0x71a9('0x7'),new AGIError(_0x71a9('0xe'),_0x172e98[_0x71a9('0x13')]));});_0x1875a0['on'](_0x71a9('0x14'),function(){_0x10fd72['emit'](_0x71a9('0x14'),new AGIError(_0x71a9('0x15')));});}process['nextTick'](function(){_0x35897a();});};util[_0x71a9('0x16')](AGIServer,EventEmitter);module[_0x71a9('0x17')]=function(_0x101504,_0x2602d,_0x3c923a){return new AGIServer(_0x101504,_0x2602d,_0x3c923a);};