Built motion from commit (unavailable).|2.5.2
[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 _0xe489=['./error','./channel','127.0.0.1','call','emit','error','E_AGI_ARGUMENT_PORT','createServer','listen','listening','connection','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','destroy','E_AGI_SERVER_MAXCONNECTION','code','close','nextTick','inherits','exports','util','net','EventEmitter'];(function(_0x56a06f,_0x183813){var _0x3309ac=function(_0x562fb0){while(--_0x562fb0){_0x56a06f['push'](_0x56a06f['shift']());}};_0x3309ac(++_0x183813);}(_0xe489,0x9e));var _0x9e48=function(_0x4a2001,_0x3cce7b){_0x4a2001=_0x4a2001-0x0;var _0x50e70f=_0xe489[_0x4a2001];return _0x50e70f;};'use strict';var util=require(_0x9e48('0x0'));var net=require(_0x9e48('0x1'));var EventEmitter=require('events')[_0x9e48('0x2')];var AGIError=require(_0x9e48('0x3'));var AGIChannel=require(_0x9e48('0x4'));var AGIServer=function(_0x1e9e0b,_0x1c874c,_0x5f372b){var _0x5f02d6=this,_0x1e9e0b=_0x1e9e0b||0x11dd,_0x1c874c=_0x1c874c||_0x9e48('0x5'),_0x9b6c19=null,_0x42747f=0x0;EventEmitter[_0x9e48('0x6')](_0x5f02d6);function _0x4b9d5e(){if(!_0x1e9e0b){_0x5f02d6[_0x9e48('0x7')](_0x9e48('0x8'),new AGIError(_0x9e48('0x9')));return![];}_0x9b6c19=net[_0x9e48('0xa')]();_0x9b6c19[_0x9e48('0xb')](_0x1e9e0b,_0x1c874c);_0x9b6c19['on']('listening',function(){_0x5f02d6[_0x9e48('0x7')](_0x9e48('0xc'));});_0x9b6c19['on'](_0x9e48('0xd'),function(_0x2b617b){_0x9b6c19['getConnections'](function(_0x343a37,_0x397b82){if(_0x343a37){_0x5f02d6[_0x9e48('0x7')](_0x9e48('0x8'),new AGIError(_0x9e48('0xe'),_0x343a37));}else if(_0x5f372b&&_0x5f372b<0x0){_0x5f02d6[_0x9e48('0x7')](_0x9e48('0x8'),new AGIError(_0x9e48('0xf')));_0x2b617b[_0x9e48('0x10')]();}else if(_0x5f372b&&_0x5f372b>0x0&&_0x5f372b<_0x397b82){_0x42747f+=0x1;_0x5f02d6['emit']('error',new AGIError(_0x9e48('0x11'),_0x42747f));_0x2b617b[_0x9e48('0x10')]();}else{var _0x52bdba=new AGIChannel(_0x2b617b);_0x52bdba['on']('ready',function(){_0x5f02d6[_0x9e48('0x7')]('connection',_0x52bdba);});}});});_0x9b6c19['on'](_0x9e48('0x8'),function(_0x5ac1ef){_0x5f02d6[_0x9e48('0x7')](_0x9e48('0x8'),new AGIError(_0x9e48('0xe'),_0x5ac1ef[_0x9e48('0x12')]));});_0x9b6c19['on']('close',function(){_0x5f02d6[_0x9e48('0x7')](_0x9e48('0x13'),new AGIError('E_AGI_SERVER_CLOSE'));});}process[_0x9e48('0x14')](function(){_0x4b9d5e();});};util[_0x9e48('0x15')](AGIServer,EventEmitter);module[_0x9e48('0x16')]=function(_0x49c3d3,_0x5f5360,_0x10a39a){return new AGIServer(_0x49c3d3,_0x5f5360,_0x10a39a);};