function handleConnect(socket) {
	var addr = socket.remoteAddress + ':' + socket.remotePort;
	connections[addr] = socket;
	socket.on('close', function close() {
		delete connections[addr];
	});
	log.info('REPL connection opened: %s', addr);
	var r = repl.start({
		prompt: config.getGsid() + '> ',
		input: socket,
		output: socket,
		terminal: true,
		eval: getReplEval(addr, socket),
		writer: function passthrough(data) {
			return data;
		},
	});
	r.on('exit', function onReplExit() {
		socket.end();
		log.info('REPL connection closed: %s', addr);
	});
	// make some things available in the REPL context
	r.context.socket = socket;
	r.context.pers = pers;
	r.context.admin = gsjsBridge.getAdmin();
	r.context.api = globalApi;
	r.context.gsrpc = rpcApi;
	r.context.slack = slack.getClient();
	r.context.rpc = rpc;
	r.context.config = config;
	r.context.logging = logging;
	r.context.bunyan = bunyan;
}
Exemple #2
0
/**
 * Wrapper around {@link module:data/rpc~handleRequest|handleRequest}
 * for GSJS admin object calls.
 *
 * @param {string} callerId ID of the calling component (for logging)
 * @param {string} fname name of the GSJS admin function to call
 * @param {array} argsObject object containing options/parameters
 * @param {function} callback callback for the RPC library, returning
 *        the result (or errors) to the remote caller
 */
function adminRequest(callerId, fname, argsObject, callback) {
	handleRequest(callerId, gsjsBridge.getAdmin(), fname, [argsObject], callback);
}
exports.apiAdminCall = function apiAdminCall(methodName, args) {
	log.debug('global.apiAdminCall(%s, %s)', methodName, args);
	//TODO: forwarding to other game servers
	gsjsBridge.getAdmin()[methodName](args);
};
Exemple #4
0
/**
 * Wrapper around {@link module:data/rpc~handleRequest|handleRequest}
 * for GSJS admin object calls.
 *
 * @param {string} callerId ID of the calling component (for logging)
 * @param {string} fname name of the GSJS admin function to call
 * @param {array} argsObject object containing options/parameters
 * @param {function} callback callback for the RPC library, returning
 *        the result (or errors) to the remote caller
 */
function adminRequest(callerId, fname, argsObject, callback) {
	var gsjsBridge = require('model/gsjsBridge');
	handleRequest(callerId, gsjsBridge.getAdmin(), null, fname, [argsObject],
		callback);
}