diff --git a/query-game-server.html b/query-game-server.html index 48c459a..ecb1828 100644 --- a/query-game-server.html +++ b/query-game-server.html @@ -7,7 +7,10 @@ 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, @@ -56,7 +59,7 @@
- Query port for the server (not always the same as the join port) + 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.
@@ -71,6 +74,33 @@ Enter "online" or "offline" (without quotes) to filter out the state you don't want.
+ +
+ + +
+
+ + Number of attempts to query server in case of failure. +
+ +
+ + +
+
+ + Milliseconds to wait for a single packet. Beware that increasing this will cause many queries to take longer even if the server is online. +
+ +
+ + +
+
+ + Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first. +
\ No newline at end of file diff --git a/query-game-server.js b/query-game-server.js index f25155c..b2be406 100644 --- a/query-game-server.js +++ b/query-game-server.js @@ -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';