Built motion from commit 7ab0e143.|2.5.49
[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 _0xb6b2=['emit','error','E_AGI_ARGUMENT_PORT','createServer','listen','listening','getConnections','E_AGI_SERVER_ERROR','E_AGI_SERVER_VOICE_DISABLED','destroy','E_AGI_SERVER_MAXCONNECTION','connection','code','inherits','exports','util','net','events','./error','./channel','127.0.0.1','call'];(function(_0xabbaf2,_0x9e0b15){var _0x32c337=function(_0x2827c1){while(--_0x2827c1){_0xabbaf2['push'](_0xabbaf2['shift']());}};_0x32c337(++_0x9e0b15);}(_0xb6b2,0x93));var _0x2b6b=function(_0x4da086,_0x82bc61){_0x4da086=_0x4da086-0x0;var _0x13f09f=_0xb6b2[_0x4da086];return _0x13f09f;};'use strict';var util=require(_0x2b6b('0x0'));var net=require(_0x2b6b('0x1'));var EventEmitter=require(_0x2b6b('0x2'))['EventEmitter'];var AGIError=require(_0x2b6b('0x3'));var AGIChannel=require(_0x2b6b('0x4'));var AGIServer=function(_0x161927,_0x38fe49,_0x2734af){var _0x51c9f1=this,_0x161927=_0x161927||0x11dd,_0x38fe49=_0x38fe49||_0x2b6b('0x5'),_0x5ecc08=null,_0x559971=0x0;EventEmitter[_0x2b6b('0x6')](_0x51c9f1);function _0x26b054(){if(!_0x161927){_0x51c9f1[_0x2b6b('0x7')](_0x2b6b('0x8'),new AGIError(_0x2b6b('0x9')));return![];}_0x5ecc08=net[_0x2b6b('0xa')]();_0x5ecc08[_0x2b6b('0xb')](_0x161927,_0x38fe49);_0x5ecc08['on'](_0x2b6b('0xc'),function(){_0x51c9f1[_0x2b6b('0x7')](_0x2b6b('0xc'));});_0x5ecc08['on']('connection',function(_0x40cf4b){_0x5ecc08[_0x2b6b('0xd')](function(_0x3f7891,_0x2742a9){if(_0x3f7891){_0x51c9f1[_0x2b6b('0x7')](_0x2b6b('0x8'),new AGIError(_0x2b6b('0xe'),_0x3f7891));}else if(_0x2734af&&_0x2734af<0x0){_0x51c9f1[_0x2b6b('0x7')](_0x2b6b('0x8'),new AGIError(_0x2b6b('0xf')));_0x40cf4b[_0x2b6b('0x10')]();}else if(_0x2734af&&_0x2734af>0x0&&_0x2734af<_0x2742a9){_0x559971+=0x1;_0x51c9f1[_0x2b6b('0x7')](_0x2b6b('0x8'),new AGIError(_0x2b6b('0x11'),_0x559971));_0x40cf4b[_0x2b6b('0x10')]();}else{var _0x422fd5=new AGIChannel(_0x40cf4b);_0x422fd5['on']('ready',function(){_0x51c9f1[_0x2b6b('0x7')](_0x2b6b('0x12'),_0x422fd5);});}});});_0x5ecc08['on'](_0x2b6b('0x8'),function(_0x2216db){_0x51c9f1[_0x2b6b('0x7')](_0x2b6b('0x8'),new AGIError(_0x2b6b('0xe'),_0x2216db[_0x2b6b('0x13')]));});_0x5ecc08['on']('close',function(){_0x51c9f1[_0x2b6b('0x7')]('close',new AGIError('E_AGI_SERVER_CLOSE'));});}process['nextTick'](function(){_0x26b054();});};util[_0x2b6b('0x14')](AGIServer,EventEmitter);module[_0x2b6b('0x15')]=function(_0x51534f,_0x3a572c,_0x27397){return new AGIServer(_0x51534f,_0x3a572c,_0x27397);};