Built motion from commit (unavailable).|2.0.72
[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 _0xc0d1=['inherits','exports','util','net','EventEmitter','./error','0.0.0.0','emit','error','createServer','listen','listening','getConnections','E_AGI_SERVER_ERROR','E_AGI_SERVER_MAXCONNECTION','destroy','ready','connection','code','close','E_AGI_SERVER_CLOSE'];(function(_0x4d6298,_0x502f6b){var _0x57ccf0=function(_0x3cef94){while(--_0x3cef94){_0x4d6298['push'](_0x4d6298['shift']());}};_0x57ccf0(++_0x502f6b);}(_0xc0d1,0xd4));var _0x1c0d=function(_0x59ee6f,_0x450239){_0x59ee6f=_0x59ee6f-0x0;var _0x4c0979=_0xc0d1[_0x59ee6f];return _0x4c0979;};'use strict';var util=require(_0x1c0d('0x0'));var net=require(_0x1c0d('0x1'));var EventEmitter=require('events')[_0x1c0d('0x2')];var AGIError=require(_0x1c0d('0x3'));var AGIChannel=require('./channel');var AGIServer=function(_0x3cdb5c,_0x31f44c,_0x1c9294){var _0x34293e=this,_0x3cdb5c=_0x3cdb5c||0x11dd,_0x31f44c=_0x31f44c||_0x1c0d('0x4'),_0x5a3564=null,_0x37e884=0x0;EventEmitter['call'](_0x34293e);function _0x1a7918(){if(!_0x3cdb5c){_0x34293e[_0x1c0d('0x5')](_0x1c0d('0x6'),new AGIError('E_AGI_ARGUMENT_PORT'));return![];}_0x5a3564=net[_0x1c0d('0x7')]();_0x5a3564[_0x1c0d('0x8')](_0x3cdb5c,_0x31f44c);_0x5a3564['on'](_0x1c0d('0x9'),function(){_0x34293e[_0x1c0d('0x5')](_0x1c0d('0x9'));});_0x5a3564['on']('connection',function(_0x200f68){_0x5a3564[_0x1c0d('0xa')](function(_0x1bd3e2,_0x4a56b0){if(_0x1bd3e2){_0x34293e[_0x1c0d('0x5')](_0x1c0d('0x6'),new AGIError(_0x1c0d('0xb'),_0x1bd3e2));}else if(_0x1c9294&&_0x1c9294<0x0){_0x34293e[_0x1c0d('0x5')](_0x1c0d('0x6'),new AGIError('E_AGI_SERVER_VOICE_DISABLED'));_0x200f68['destroy']();}else if(_0x1c9294&&_0x1c9294>0x0&&_0x1c9294<_0x4a56b0){_0x37e884+=0x1;_0x34293e['emit'](_0x1c0d('0x6'),new AGIError(_0x1c0d('0xc'),_0x37e884));_0x200f68[_0x1c0d('0xd')]();}else{var _0x3ae39f=new AGIChannel(_0x200f68);_0x3ae39f['on'](_0x1c0d('0xe'),function(){_0x34293e['emit'](_0x1c0d('0xf'),_0x3ae39f);});}});});_0x5a3564['on'](_0x1c0d('0x6'),function(_0x3502a3){_0x34293e[_0x1c0d('0x5')](_0x1c0d('0x6'),new AGIError('E_AGI_SERVER_ERROR',_0x3502a3[_0x1c0d('0x10')]));});_0x5a3564['on'](_0x1c0d('0x11'),function(){_0x34293e[_0x1c0d('0x5')]('close',new AGIError(_0x1c0d('0x12')));});}process['nextTick'](function(){_0x1a7918();});};util[_0x1c0d('0x13')](AGIServer,EventEmitter);module[_0x1c0d('0x14')]=function(_0x50d8b6,_0x58c027,_0xdc735b){return new AGIServer(_0x50d8b6,_0x58c027,_0xdc735b);};