Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
JavaScript (node.js) port of GbxRemote by Nadeo, which is built on Incutio XML-RPC Library.
Used to communicate with ManiaPlanet servers.
Note: The API may, or may not change!
npm install gbxremote
Look in /examples/ for all examples.
The following examples expects that var gbxremote = require('gbxremote')
.
To connect to a server, use var client = gbxremote.createClient(port, [host]);
Examples of ways to connect to the server:
// Connect with port only
var client = gbxremote.createClient(5000);
client.on('connect', onConnect);
// Connect with port and hostname
var client = gbxremote.createClient(5000, 'localhost');
client.on('connect', onConnect);
// Connect with port and ip
var client = gbxremote.createClient(5000, '127.0.0.1');
client.on('connect', onConnect);
// Create client and connect explicitly
var client = new gbxremote.Client(5000, 'localhost');
client.connect().then(onConnect);
Queries are sent to the server by calling client.query(method, [params]);
client.query
returns a promise.
Queries before the connect event has been emitted will be queued and sent on connect!
var client = gbxremote.createClient(5000);
client.on('connect', function() {
// GetVersion does not take any params.
client.query('GetVersion').then(function (res) {
console.log('Server version:', res.join(', '));
}).catch(function(err) {
console.error('Error when querying server:', err);
});
// GetPlayerInfo takes 2 parameters, 1 optional.
// GetPlayerInfo(string login, [int compatibility])
client.query('GetPlayerInfo', ['minigod']).then(function (res) {
console.log('Player info:');
console.log(res);
}).catch(function (err) {
console.error('Error getting player info:', err);
});
});
client.terminate();
Emitted when connection to the server is successfull.
Ready to receive queries!
var client = gbxremote.createClient(5000);
client.on('connect', function() {
console.log('Connection successfull! Lets do some queries!');
client.query('EnableCallbacks', true);
});
If there is a problem connecting, the 'connect' event will not be emitted, the 'error' event will be emitted with the exception.
Emitted when:
var client = gbxremote.createClient(5000);
client.on('error', function(err) {
console.error('Connection failed: ' + err);
});
After sending EnableCallbacks(true)
to the server, it will send you callbacks when stuff happend on the server.
Eg:
ManiaPlanet.ServerStart
ManiaPlanet.ServerStop
ManiaPlanet.PlayerConnect
ManiaPlanet.PlayerChat
See the full list of callbacks
var client = gbxremote.createClient(5000);
client.on('connect', function() {
client.query('SetApiVersion', ['2012-06-19']);
client.query('EnableCallbacks', [true]);
});
client.on('callback', function(method, params) {
console.log("Callback from server: %s - %d params", method, params.length);
// This would be the typical place to have a switch statement. Please dont do that. Use the events, as shown below.
});
Callbacks will also emit separate events for each method. It's hard to explain. Learn from example:
var client = gbxremote.createClient(5000);
client.on('connect', function() {
// Before enabling callbacks, make sure you set the latest API.
client.query('SetApiVersion', ['2012-06-19']);
client.query('EnableCallbacks', [true]);
});
// ManiaPlanet.PlayerConnect(string Login, bool IsSpectator);
client.on('ManiaPlanet.PlayerConnect', function(params) {
console.log('%s just joined as a %s', params[0], params[1] ? 'spectator' : 'player');
});
// ManiaPlanet.PlayerDisconnect(string Login);
client.on('ManiaPlanet.PlayerDisconnect', function(params) {
console.log('%s left the server', params[0]);
});
These events can basically take over the big switch statements that is normal in todays server controllers.
Emitted once the socket is fully closed. The argument had_error is a boolean which says if the socket was closed due to a transmission error.
var client = gbxremote.createClient(5000);
client.on('connect', function() {
// Connected...
// Do stuff?
// Disconnect
client.terminate();
});
client.on('close', function(had_error) {
console.log('Connection to the server has been closed');
});
Released under the MIT license. See the LICENSE file for the complete wording.
FAQs
A pure JavaScript GBXRemote client.
We found that gbxremote demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.