- update version to 2.1.1

- node description updated
- node now errors if msg.host or msg.port is left blank and not configured on the node
- server type & host is not required when configuring the node since it can be passed in via the inputs
- when modifying a node in the editor you can now view available server types at the bottom of the properties. This is parsed from the gamedig readme.
- Update gamedig version
- package-lock.json added
- palette label changed to "Query Game Server"
This commit is contained in:
2021-09-04 23:00:32 -06:00
parent 09c763a605
commit e2e8119d7f
6 changed files with 1441 additions and 69 deletions

View File

@@ -4,8 +4,8 @@
color: '#a6bbcf',
defaults: {
name: { value: '' },
server_type: { value: '', required: true },
host: { value: '', required: true },
server_type: { value: '' },
host: { value: '' },
port: { value: '' },
halt_if: { value: '' },
max_attempts: { value: '' },
@@ -15,6 +15,7 @@
inputs:1,
outputs:1,
icon: "icons/server.png",
paletteLabel: "Query Game Server",
label: function() {
if(this.name){
return this.name;
@@ -25,11 +26,36 @@
}
return 'Query Game Server';
},
oneditprepare: function() {
$.getJSON('/gamedig/types', function(data) {
let html = '<table>' +
'<thead id="query-game-server-types-table"><tr><td><strong>Type</strong></td><td><strong>Name</strong></td></tr></thead>' +
'<tbody id="query-game-server-type-rows">';
for(var type in data) {
html += "<tr class=\"query-game-server-type-row\">" +
"<td>"+type+"</td>" +
"<td>"+data[type]+"</td>" +
"</tr>";
}
html += '</tbody>' +
'</table>';
$("#query-game-server-types").html(html);
});
}
});
</script>
<script type="text/x-red" data-template-name="query-game-server">
<script type="text/html" data-template-name="query-game-server">
<style>
#query-game-server-types table, #query-game-server-types th, #query-game-server-types td {
border: 1px solid black;
border-collapse: collapse;
}
#query-game-server-types td {
padding: 3px;
}
</style>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
@@ -39,27 +65,26 @@
<label for="node-input-server_type"><i class="fa fa-cube"></i> Server Type</label>
<input type="text" id="node-input-server_type">
</div>
<div class="form-row">
<label>&nbsp;</label>
<span>Check <a href="https://github.com/sonicsnes/node-gamedig#games-list" style="color:#0000EE;" target="_blank">here</a> for a list of supported server types.</span>
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
View server types <a href="#gamdig-types" style="color:#0000EE;text-decoration: underline;">below</a>.
</div>
<div class="form-row">
<label for="node-input-host"><i class="fa fa-server"></i> Host</label>
<input type="text" id="node-input-host" />
<input type="text" id="node-input-host" placeholder="msg.host" />
</div>
<div class="form-row">
<label>&nbsp;</label>
<span>Host without port</span>
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Host without port. Uses <code>msg.host</code> if left blank.
</div>
<div class="form-row">
<label for="node-input-port"><i class="fa fa-server"></i> Port</label>
<input type="text" id="node-input-port" />
<label for="node-input-port"><i class="fa fa-ethernet"></i> Port</label>
<input type="text" id="node-input-port" placeholder="msg.host" />
</div>
<div class="form-row">
<label>&nbsp;</label>
<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 style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Query port for the server (join and query port may differ).
If this is left blank it will use the default port for the server type specified.
Uses <code>msg.port</code> if left blank.
</div>
<div class="form-row">
@@ -70,112 +95,145 @@
<option value="offline">Offline</option>
</select>
</div>
<div class="form-row">
<label>&nbsp;</label>
<span>Enter "online" or "offline" (without quotes) to filter out the state you don't want.</span>
<div style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Filter messages based on server status
</div>
<div class="form-row">
<label for="node-input-max_attempts"><i class="fa fa-server"></i> Max Attempts</label>
<label for="node-input-max_attempts"><i class="fa fa-cogs"></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 style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Number of attempts to query server in case of failure.
</div>
<div class="form-row">
<label for="node-input-socket_timeout"><i class="fa fa-server"></i> Socket Timeout</label>
<label for="node-input-socket_timeout"><i class="fa fa-cogs"></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 style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Milliseconds to wait for a single packet. Beware that increasing this will cause many queries to take longer even if the server is online.
</div>
<div class="form-row">
<label for="node-input-attempt_timeout"><i class="fa fa-server"></i> Attempt Timeout</label>
<label for="node-input-attempt_timeout"><i class="fas fa-cogs"></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 style="margin-left: 105px;width: 50%;margin-bottom: 10px;margin-top: -10px;">
Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first.
</div>
<h3 id="gamdig-types">Server Types</h3>
<p>
Search available types below.<br>
You can also view the list <a href="https://github.com/gamedig/node-gamedig#games-list" target="_blank" style="color:#0000EE;text-decoration: underline;">here</a>.
</p>
<div class="row">
<input type="text" id="query-game-server-types-search" placeholder="Search types.." style="margin-bottom: 10px;" />
</div>
<div id="query-game-server-types"></div>
<script type="text/javascript">
$("#query-game-server-types-search").on("input", function(e) {
let value = $(this).val();
if(value.length) {
$(".query-game-server-type-row").each(function(i, elem){
console.log('yay', $(elem).text(), value, $(elem).text().indexOf(value));
if($(elem).text().toLowerCase().indexOf(value.toLowerCase()) > -1) {
$(elem).show();
} else {
$(elem).hide();
}
});
return;
}
$(".query-game-server-type-row").show();
});
</script>
</script>
<script type="text/x-red" data-help-name="query-game-server">
<p>Query a Game Server</p>
<h3>Config</h3>
<dl class="message-properties">
<dt>Server Type <span class="property-type">string</span></dt>
<dt>Host <span class="property-type">string</span></dt>
<dt>Port <span class="property-type">integer</span></dt>
<dt>Halt If <span class="property-type">string</span></dt>
</dl>
<script type="text/html" data-help-name="query-game-server">
<p>Query most Game/Voice server's using the <a href="https://github.com/gamedig/node-gamedig" target="_blank">GameDig</a> library.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt class="optional">
msg.server_type <span class="property-type">string</span>
msg.server_type <span class="property-type">string | null</span>
</dt>
<dd>Server type to query. Check <a href="https://github.com/sonicsnes/node-gamedig#games-list" style="color:#0000EE;" target="_blank">here</a> for a list of supported server types</dd>
<dd>Server type to query. View available types either at the bottom of the node editor or <a href="https://github.com/sonicsnes/node-gamedig#games-list" style="color:#0000EE;" target="_blank">click here</a>. Ignored if configured on the node.</dd>
<dt class="optional">
msg.host <span class="property-type">string</span>
msg.host <span class="property-type">string | null</span>
</dt>
<dd>Server IP/Hostname</dd>
<dd>Server IP/Hostname. Ignored if configured on the node.</dd>
<dt class="optional">
msg.port <span class="property-type">integer</span>
msg.port <span class="property-type">integer | null</span>
</dt>
<dd>Query port of the server</dd>
<dd>Query port of the server. Ignored if configured on the node. Uses default query port for the server type if left empty.</dd>
<dt class="optional">
msg.max_attempts <span class="property-type">integer</span>
msg.max_attempts <span class="property-type">integer | null</span>
</dt>
<dd>Number of attempts to query server in case of failure.</dd>
<dd>Number of attempts to query server in case of failure. Ignored if configured on the node.</dd>
<dt class="optional">
msg.socket_timeout <span class="property-type">integer</span>
msg.socket_timeout <span class="property-type">integer | null</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>
<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. Ignored if configured on the node.</dd>
<dt class="optional">
msg.attempt_timeout <span class="property-type">integer</span>
msg.attempt_timeout <span class="property-type">integer | null</span>
</dt>
<dd>Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first.</dd>
<dd>Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first. Ignored if configured on the node.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>
msg.payload <span class="property-type">string</span>
</dt>
<dd>Returns either <code>online</code> or <code>offline</code> depending on if we successfully query the server or not.</dd>
<dd>Returns either <code>online</code> or <code>offline</code>.</dd>
<dt>
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>
<dd>Returns back the results we got from GameDig. Click <a href="https://github.com/sonicsnes/node-gamedig#return-value" target="_blank" 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>
<dd>Server type to query. View available types either at the bottom of the node editor or <a href="https://github.com/sonicsnes/node-gamedig#games-list" style="color:#0000EE;" target="_blank">click here</a>. Ignored if configured on the node.</dd>
<dt>
msg.host <span class="property-type">string</span>
</dt>
<dd>Server IP/Hostname. Ignored if configured on the node.</dd>
<dt>
msg.port <span class="property-type">integer</span>
</dt>
<dt>
msg.halt_if <span class="property-type">string</span>
</dt>
<dd>Query port of the server. Ignored if configured on the node.</dd>
<dt>
msg.max_attempts <span class="property-type">integer</span>
</dt>
<dd>Number of attempts to query server in case of failure. Ignored if configured on the node.</dd>
<dt>
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. Ignored if configured on the node.</dd>
<dt>
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. Ignored if configured on the node.</dd>
</dl>
</script>