mirror of
https://github.com/skylord123/node-red-contrib-gamedig.git
synced 2025-07-08 11:40:59 -06:00
Compare commits
6 Commits
539f7fe21f
...
6836b82b0b
Author | SHA1 | Date | |
---|---|---|---|
6836b82b0b | |||
52bddfa603 | |||
4770cfdc53 | |||
3fdd0c1539 | |||
b8ec64d854 | |||
560d24f068 |
19
README.md
19
README.md
@ -1,2 +1,19 @@
|
|||||||
# node-red-contrib-gamedig
|
# node-red-contrib-gamedig
|
||||||
Query for the status of any game server using Node Red
|
|
||||||
|
Query for the status of any game server using Node-RED.
|
||||||
|
|
||||||
|
This package adds the node "Query Game Server" that uses the NPM package [GameDig](https://www.npmjs.com/package/gamedig) to query if a server is online or not and if so returns the data of the server.
|
||||||
|
|
||||||
|
You can pass the server type, host, and port on the input message or define them on the node (settings defined on the node will override msg values).
|
||||||
|
|
||||||
|
### Usage Examples
|
||||||
|
#### Inserting query data into InfluxDB and using Grafana to view results
|
||||||
|

|
||||||
|
I created a post on my website about how to use this node to query gameservers and store the results in InfluxDB. I then give a dashboard in Grafana that can be used to display the data. Check it out here:
|
||||||
|
https://skylar.tech/tracking-game-server-statistics-using-node-red-influxdb-and-grafana/
|
||||||
|
|
||||||
|
### Developers
|
||||||
|
So far me (skylord123) is the only person that has contributed towards this package. Feel free to do any pull-requests to get your name here!
|
||||||
|
|
||||||
|
### License
|
||||||
|
This project is licensed under the MIT License. Check [here](LICENSE) for more information.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-contrib-gamedig",
|
"name": "node-red-contrib-gamedig",
|
||||||
"version": "1.0.0",
|
"version": "1.1.5",
|
||||||
"description": "Query for the status of any game server using node-red",
|
"description": "Query for the status of any game server using node-red",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -12,6 +12,7 @@
|
|||||||
"url": "https://github.com/skylord123/node-red-contrib-gamedig/issues"
|
"url": "https://github.com/skylord123/node-red-contrib-gamedig/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/skylord123/node-red-contrib-gamedig#readme",
|
"homepage": "https://github.com/skylord123/node-red-contrib-gamedig#readme",
|
||||||
|
"keywords": [ "node-red", "gamedig", "query game server" ],
|
||||||
"node-red": {
|
"node-red": {
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"query-game-server": "query-game-server.js"
|
"query-game-server": "query-game-server.js"
|
||||||
|
@ -9,44 +9,45 @@ module.exports = function(RED) {
|
|||||||
this.halt_if = config.halt_if;
|
this.halt_if = config.halt_if;
|
||||||
var node = this;
|
var node = this;
|
||||||
node.on('input', function(msg) {
|
node.on('input', function(msg) {
|
||||||
var serverInfo = {
|
|
||||||
'type': node.server_type,
|
if(node.server_type) {
|
||||||
'host': node.host
|
msg.server_type = node.server_type;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
if(node.host) {
|
||||||
|
msg.host = node.host;
|
||||||
|
}
|
||||||
|
|
||||||
if(node.port) {
|
if(node.port) {
|
||||||
serverInfo['port'] = node.port;
|
msg.port = node.port;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(msg.server_type) {
|
if(node.halt_if) {
|
||||||
serverInfo['type'] = msg.server_type;
|
msg.halt_if = node.halt_if;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(msg.host) {
|
Gamedig.query({
|
||||||
serverInfo['host'] = msg.host;
|
'type': msg.server_type,
|
||||||
}
|
'host': msg.host
|
||||||
|
})
|
||||||
if(msg.port) {
|
|
||||||
serverInfo['port'] = msg.port;
|
|
||||||
}
|
|
||||||
|
|
||||||
Gamedig.query(serverInfo)
|
|
||||||
.then(function(state) {
|
.then(function(state) {
|
||||||
msg.payload = 'online';
|
msg.payload = 'online';
|
||||||
msg.data = state;
|
msg.data = state;
|
||||||
if (msg.payload === node.halt_if) {
|
if (msg.payload === msg.halt_if) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
node.send(msg);
|
node.status({fill:"green",shape:"dot",text: 'Online ' + msg.data.players.length + ' players' });
|
||||||
|
node.send(msg);
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
msg.payload = 'offline';
|
msg.payload = 'offline';
|
||||||
msg.data = {
|
msg.data = {
|
||||||
'error': error
|
'error': error
|
||||||
};
|
};
|
||||||
if (msg.payload === node.halt_if) {
|
if (msg.payload === msg.halt_if) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
node.send(msg);
|
node.status({fill:"red", shape:"dot", text: 'Offline'});
|
||||||
|
node.send(msg);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user