e1f4d759ff1ac1b84502335fb82485e00cc4a282
[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 _0xa854=['ready','code','close','E_AGI_SERVER_CLOSE','nextTick','exports','util','net','events','EventEmitter','./error','127.0.0.1','error','E_AGI_ARGUMENT_PORT','createServer','listen','listening','emit','connection','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','destroy','E_AGI_SERVER_MAXCONNECTION'];(function(_0x11da3b,_0x3c073a){var _0x30fefc=function(_0x1ce7f4){while(--_0x1ce7f4){_0x11da3b['push'](_0x11da3b['shift']());}};_0x30fefc(++_0x3c073a);}(_0xa854,0x103));var _0x4a85=function(_0x58c257,_0x18bc49){_0x58c257=_0x58c257-0x0;var _0x1b8cd1=_0xa854[_0x58c257];return _0x1b8cd1;};'use strict';var util=require(_0x4a85('0x0'));var net=require(_0x4a85('0x1'));var EventEmitter=require(_0x4a85('0x2'))[_0x4a85('0x3')];var AGIError=require(_0x4a85('0x4'));var AGIChannel=require('./channel');var AGIServer=function(_0x135ea5,_0x498101,_0x388052){var _0x5bd2dd=this,_0x135ea5=_0x135ea5||0x11dd,_0x498101=_0x498101||_0x4a85('0x5'),_0x494d91=null,_0x445a95=0x0;EventEmitter['call'](_0x5bd2dd);function _0xb1605c(){if(!_0x135ea5){_0x5bd2dd['emit'](_0x4a85('0x6'),new AGIError(_0x4a85('0x7')));return![];}_0x494d91=net[_0x4a85('0x8')]();_0x494d91[_0x4a85('0x9')](_0x135ea5,_0x498101);_0x494d91['on'](_0x4a85('0xa'),function(){_0x5bd2dd[_0x4a85('0xb')](_0x4a85('0xa'));});_0x494d91['on'](_0x4a85('0xc'),function(_0x95de02){_0x494d91['getConnections'](function(_0x45cff9,_0x2232dd){if(_0x45cff9){_0x5bd2dd[_0x4a85('0xb')](_0x4a85('0x6'),new AGIError(_0x4a85('0xd'),_0x45cff9));}else if(_0x388052&&_0x388052<0x0){_0x5bd2dd[_0x4a85('0xb')](_0x4a85('0x6'),new AGIError(_0x4a85('0xe')));_0x95de02[_0x4a85('0xf')]();}else if(_0x388052&&_0x388052>0x0&&_0x388052<_0x2232dd){_0x445a95+=0x1;_0x5bd2dd['emit'](_0x4a85('0x6'),new AGIError(_0x4a85('0x10'),_0x445a95));_0x95de02[_0x4a85('0xf')]();}else{var _0x153d39=new AGIChannel(_0x95de02);_0x153d39['on'](_0x4a85('0x11'),function(){_0x5bd2dd[_0x4a85('0xb')](_0x4a85('0xc'),_0x153d39);});}});});_0x494d91['on'](_0x4a85('0x6'),function(_0x1922cb){_0x5bd2dd[_0x4a85('0xb')](_0x4a85('0x6'),new AGIError('E_AGI_SERVER_ERROR',_0x1922cb[_0x4a85('0x12')]));});_0x494d91['on'](_0x4a85('0x13'),function(){_0x5bd2dd['emit'](_0x4a85('0x13'),new AGIError(_0x4a85('0x14')));});}process[_0x4a85('0x15')](function(){_0xb1605c();});};util['inherits'](AGIServer,EventEmitter);module[_0x4a85('0x16')]=function(_0x2eb00a,_0x457739,_0x496b8a){return new AGIServer(_0x2eb00a,_0x457739,_0x496b8a);};