core/handler.js
function (msgtype, event) {
	
		// we only forward for non-SR user-defined events at lobby
		if (SR.Settings.SERVER_INFO.type !== 'lobby' || msgtype.startsWith('SR'))
			return false;
		
		// check if we're lobby and same-name app servers are available
		var list = SR.AppConn.queryAppServers();
		LOG.sys('check forward for: ' + msgtype + ' app server size: ' + Object.keys(list).length, l_name);
	
		var minload_id = undefined;
		var minload = 10000;
		
		for (var id in list) {
			var info = list[id];
			if (info.type === 'app' && info.name === SR.Settings.SERVER_INFO.name) {
				LOG.warn('found forward target [' + id + '] loading: ' + info.usercount, l_name);
				if (info.usercount < minload) {
					minload_id = id;
					minload = info.usercount;
				}
			}
		}
			
		// an app server with minimal loading is available, relay the event
		if (minload_id) {
			SR.RPC.relayEvent(minload_id, msgtype, event);	
			return true;
		}
		
		// no need to forward, local execution
		return false;
	}
function (msgtype, event) {
	
		// we only forward for non-SR user-defined events at lobby
		if (SR.Settings.SERVER_INFO.type !== 'lobby' || msgtype.startsWith('SR'))
			return false;
		
		// check if we're lobby and same-name app servers are available
		var list = SR.AppConn.queryAppServers();
		LOG.sys('check forward for: ' + msgtype + ' app server size: ' + Object.keys(list).length, l_name);
	
		var minload_id = undefined;
		var minload = 10000;
		
		for (var id in list) {
			var info = list[id];
			if (info.type === 'app' && info.name === SR.Settings.SERVER_INFO.name) {
				LOG.warn('found forward target [' + id + '] loading: ' + info.usercount, l_name);
				if (info.usercount < minload) {
					minload_id = id;
					minload = info.usercount;
				}
			}
		}
			
		// an app server with minimal loading is available, relay the event
		if (minload_id) {
			SR.RPC.relayEvent(minload_id, msgtype, event);	
			return true;
		}
		
		// no need to forward, local execution
		return false;
	}
function ( msgtype , event ) { // we only forward for non-SR user-defined events at lobby if ( SR . Settings . SERVER_INFO . type !== 'lobby' || msgtype . startsWith ( 'SR' ) ) return false ; // check if we're lobby and same-name app servers are available var list = SR . AppConn . queryAppServers ( ) ; LOG . sys ( 'check forward for: ' + msgtype + ' app server size: ' + Object . keys ( list ) . length , l_name ) ; var minload_id = undefined ; var minload = 10000 ; for ( var id in list ) { var info = list [ id ] ; if ( info . type === 'app' && info . name === SR . Settings . SERVER_INFO . name ) { LOG . warn ( 'found forward target [' + id + '] loading: ' + info . usercount , l_name ) ; if ( info . usercount < minload ) { minload_id = id ; minload = info . usercount ; } } } // an app server with minimal loading is available, relay the event if ( minload_id ) { SR . RPC . relayEvent ( minload_id , msgtype , event ) ; return true ; } // no need to forward, local execution return false ; }
check if an event should be forwarded to another app server for execution
check if an event should be forwarded to another app server for execution