Compare commits

...

6 Commits

Author SHA1 Message Date
09c763a605 Up version to 2.0.1
- Updated readme for NPM
2019-12-09 18:44:14 -07:00
67ad3de10b Merge branch 'master' of github.com:skylord123/node-red-contrib-gamedig 2019-12-09 18:43:11 -07:00
1885f7b8a1 Up version to 2.0.0 2019-12-09 18:42:51 -07:00
072c85f78a - Fixed port not being passed through
- Added support for maxAttempts, socketTimeout, and attemptTimeout advanced options in GameDig to be configurable on the node.
- Updated help information to match new changes.
2019-12-09 18:39:53 -07:00
36afa961a3 Fix for name field not working 2019-12-09 18:13:49 -07:00
a2a4f47604 Change how names for nodes are displayed 2019-12-09 18:12:35 -07:00
3 changed files with 100 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{
"name": "node-red-contrib-gamedig",
"version": "1.1.5",
"version": "2.0.1",
"description": "Query for the status of any game server using node-red",
"repository": {
"type": "git",

View File

@ -7,17 +7,24 @@
server_type: { value: '', required: true },
host: { value: '', required: true },
port: { value: '' },
halt_if: { value: '' }
halt_if: { value: '' },
max_attempts: { value: '' },
socket_timeout: { value: '' },
attempt_timeout: { value: '' },
},
inputs:1,
outputs:1,
icon: "icons/server.png",
label: function() {
if(this.host) {
return `Query: ${this.host}`;
if(this.name){
return this.name;
}
return this.name || 'Query Game Server';
if(this.host) {
return (this.server_type ? this.server_type : 'Query') + ': ' + this.host + (this.port ? ":" + this.port : '');
}
return 'Query Game Server';
}
});
</script>
@ -52,7 +59,7 @@
</div>
<div class="form-row">
<label>&nbsp;</label>
<span>Query port for the server (not always the same as the join port)</span>
<span>Query port for the server (not always the same as the join port). If this is left blank it will use the default port for the server type specified.</span>
</div>
<div class="form-row">
@ -67,6 +74,33 @@
<label>&nbsp;</label>
<span>Enter "online" or "offline" (without quotes) to filter out the state you don't want.</span>
</div>
<div class="form-row">
<label for="node-input-max_attempts"><i class="fa fa-server"></i> Max Attempts</label>
<input type="text" id="node-input-max_attempts" placeholder="1" />
</div>
<div class="form-row">
<label>&nbsp;</label>
<span>Number of attempts to query server in case of failure.</span>
</div>
<div class="form-row">
<label for="node-input-socket_timeout"><i class="fa fa-server"></i> Socket Timeout</label>
<input type="text" id="node-input-socket_timeout" placeholder="2000" />
</div>
<div class="form-row">
<label>&nbsp;</label>
<span>Milliseconds to wait for a single packet. Beware that increasing this will cause many queries to take longer even if the server is online.</span>
</div>
<div class="form-row">
<label for="node-input-attempt_timeout"><i class="fa fa-server"></i> Attempt Timeout</label>
<input type="text" id="node-input-attempt_timeout" placeholder="10000" />
</div>
<div class="form-row">
<label>&nbsp;</label>
<span>Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first.</span>
</div>
</script>
<script type="text/x-red" data-help-name="query-game-server">
@ -92,6 +126,18 @@
msg.port <span class="property-type">integer</span>
</dt>
<dd>Query port of the server</dd>
<dt class="optional">
msg.max_attempts <span class="property-type">integer</span>
</dt>
<dd>Number of attempts to query server in case of failure.</dd>
<dt class="optional">
msg.socket_timeout <span class="property-type">integer</span>
</dt>
<dd>Milliseconds to wait for a single packet. Beware that increasing this will cause many queries to take longer even if the server is online.</dd>
<dt class="optional">
msg.attempt_timeout <span class="property-type">integer</span>
</dt>
<dd>Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
@ -103,5 +149,33 @@
msg.data <span class="property-type">object</span>
</dt>
<dd>Returns back the data we got from GameDig. Click <a href="https://github.com/sonicsnes/node-gamedig#return-value" style="color:#0000EE;">here</a> for more information on what this contains.</dd>
<dt>
msg.data.error <span class="property-type">string</span>
</dt>
<dd>Reason the server failed to query. Only returns if <code>msg.payload</code> is <code>offline</code>.</dd>
<dt>
msg.server_type <span class="property-type">string</span>
</dt>
<dt>
msg.server_type <span class="property-type">string</span>
</dt>
<dt>
msg.host <span class="property-type">string</span>
</dt>
<dt>
msg.port <span class="property-type">integer</span>
</dt>
<dt>
msg.halt_if <span class="property-type">string</span>
</dt>
<dt>
msg.max_attempts <span class="property-type">integer</span>
</dt>
<dt>
msg.socket_timeout <span class="property-type">integer</span>
</dt>
<dt>
msg.attempt_timeout <span class="property-type">integer</span>
</dt>
</dl>
</script>

View File

@ -7,6 +7,9 @@ module.exports = function(RED) {
this.host = config.host;
this.port = config.port;
this.halt_if = config.halt_if;
this.max_attempts = config.max_attempts || 1;
this.socket_timeout = config.socket_timeout || 2000;
this.attempt_timeout = config.attempt_timeout || 10000;
var node = this;
node.on('input', function(msg) {
@ -26,9 +29,25 @@ module.exports = function(RED) {
msg.halt_if = node.halt_if;
}
if(node.max_attempts) {
msg.max_attempts = node.max_attempts;
}
if(node.socket_timeout) {
msg.socket_timeout = node.socket_timeout;
}
if(node.attempt_timeout) {
msg.attempt_timeout = node.attempt_timeout;
}
Gamedig.query({
'type': msg.server_type,
'host': msg.host
'host': msg.host,
'port': msg.port,
'maxAttempts': msg.max_attempts,
'socketTimeout': msg.socket_timeout,
'attemptTimeout': msg.attempt_timeout
})
.then(function(state) {
msg.payload = 'online';