There are no logged errors, or anything in the browser console.
This is my Nodes code:
package.json
{
"name": "node-red-Minecraft-Server-Connector",
"version": "0.0.5",
"description": "Node-RED nodes to interact Minecraft Server using RCON protocol",
"author": "Dovev Golan",
"dependencies": {
"rcon-client": "latest"
},
"node-red": {
"nodes": {
"rcon-server": "./mc-server",
"rcon-command": "./mc-command"
}
}
}
mc-command.html
<script type="text/javascript">
RED.nodes.registerType('mc-command',{
category: 'Minecraft', // The category in the sidebar under which this node will appear
color: '#FFA500', // Orange color
defaults: {
server: {type: "mc-server", required: true},
},
inputs: 1,
outputs: 1,
icon: "cog", // You can specify a custom icon if you want
label: function() {
return this.name || "RCON Command";
}
});
</script>
<script type="text/html" data-template-name="mc-command">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-server"></i> Server</label>
<input type="text" id="node-input-server" placeholder="Server">
</div>
</script>
<script type="text/html" data-help-name="mc-command">
<p>This node sends RCON commands to a Minecraft server.</p>
</script>
mc-command.js
const Rcon = require('rcon-client');
module.exports = function(RED) {
function RconCommandNode(config) {
RED.nodes.createNode(this, config);
this.server = RED.nodes.getNode(config.server);
var node = this;
node.on('input', function(msg) {
const rcon = new Rcon({
host: this.server.host,
port: this.server.port,
password: this.server.password,
});
rcon.connect()
.then(() => {
return rcon.send(msg.payload);
})
.then(response => {
msg.payload = response;
rcon.end();
node.send(msg);
})
.catch(error => {
node.error(error);
});
});
}
RED.nodes.registerType("mc-command", RconCommandNode);
};
mc-server.html
<script type="text/javascript">
RED.nodes.registerType('mc-server', {
category: 'Minecraft',
color: '#a6bbcf',
icon: "cog",
defaults: {
host: {value: "", required: true},
port: {value: "", required: true},
password: {value: "", required: true}
},
label: function() {
return this.name || "RCON Server";
}
});
</script>
<!-- More code for HTML form here -->
mc-server.js
module.exports = function(RED) {
function RconServerConfigNode(config) {
RED.nodes.createNode(this, config);
this.host = config.host;
this.port = config.port;
this.password = config.password;
}
RED.nodes.registerType("mc-server", RconServerConfigNode);
}
What am I doing wrong?