core/app_connector.js
function (ip_port, onDone) {

	if (l_appConnector === undefined) {
		LOG.warn('appConnector not init, cannot connect');
		return;
	}
	
	// retrieve from previous connect attempt, also store for later connect attempt
	// TODO: will need to change when lobby port becomes not fixed
	ip_port = ip_port || l_ip_port;
	l_ip_port = ip_port;
	
	// store callback to be called later
	// TODO: better approach?
	l_onDone = onDone || l_onDone;
	
	l_appConnector.connect(ip_port, function (err, socket) {
		if (err) {
			LOG.error('connection to manager: ' + ip_port.IP + ':' + ip_port.port + ' fail, try again in ' + l_timeoutReconnect + ' ms');
			
			// TODO: do not keep trying, but rather try to re-connect after being notified by monitor server
			setTimeout(l_connect, l_timeoutReconnect);
		}
		// connection is successful
		else {
			LOG.warn('connection to manager: ' + ip_port.IP + ':' + ip_port.port + ' established');
			l_register();
		}
	});
}
function (ip_port, onDone) {

	if (l_appConnector === undefined) {
		LOG.warn('appConnector not init, cannot connect');
		return;
	}
	
	// retrieve from previous connect attempt, also store for later connect attempt
	// TODO: will need to change when lobby port becomes not fixed
	ip_port = ip_port || l_ip_port;
	l_ip_port = ip_port;
	
	// store callback to be called later
	// TODO: better approach?
	l_onDone = onDone || l_onDone;
	
	l_appConnector.connect(ip_port, function (err, socket) {
		if (err) {
			LOG.error('connection to manager: ' + ip_port.IP + ':' + ip_port.port + ' fail, try again in ' + l_timeoutReconnect + ' ms');
			
			// TODO: do not keep trying, but rather try to re-connect after being notified by monitor server
			setTimeout(l_connect, l_timeoutReconnect);
		}
		// connection is successful
		else {
			LOG.warn('connection to manager: ' + ip_port.IP + ':' + ip_port.port + ' established');
			l_register();
		}
	});
}
function ( ip_port , onDone ) { if ( l_appConnector === undefined ) { LOG . warn ( 'appConnector not init, cannot connect' ) ; return ; } // retrieve from previous connect attempt, also store for later connect attempt // TODO: will need to change when lobby port becomes not fixed ip_port = ip_port || l_ip_port ; l_ip_port = ip_port ; // store callback to be called later // TODO: better approach? l_onDone = onDone || l_onDone ; l_appConnector . connect ( ip_port , function ( err , socket ) { if ( err ) { LOG . error ( 'connection to manager: ' + ip_port . IP + ':' + ip_port . port + ' fail, try again in ' + l_timeoutReconnect + ' ms' ) ; // TODO: do not keep trying, but rather try to re-connect after being notified by monitor server setTimeout ( l_connect , l_timeoutReconnect ) ; } // connection is successful else { LOG . warn ( 'connection to manager: ' + ip_port . IP + ':' + ip_port . port + ' established' ) ; l_register ( ) ; } } ) ; }
attempt to connect to manager
attempt to connect to manager