Separate connection related data from host data

Split out host specific data from RegisterHostData that is not related
to the establishment of a connection to the controller into it's own
HostInfoUpdate event.  This allows this data to be updated when the
config values they are taken from are changed.
This commit is contained in:
Hornwitser committed 2024-01-15 22:19:38 +01:00
1 parent 790f880e98
commit 688ddc529b
8 files changed
+94 -42

No files matched your search

+15
View File
@@ -288,6 +288,9 @@ export default class Host extends lib.Link {
this.config = hostConfig;
this.config.on("fieldChanged", (name, curr, prev) => {
if (name === "host.name" || name === "host.public_address") {
this.sendHostUpdate();
}
lib.invokeHook(this.plugins, "onHostConfigFieldChanged", name, curr, prev);
});
@@ -301,6 +304,7 @@ export default class Host extends lib.Link {
return;
}
this.sendHostUpdate();
this.updateInstances().catch((err) => {
if (err instanceof lib.SessionLost) {
return undefined;
@@ -992,6 +996,17 @@ export default class Host extends lib.Link {
await fs.remove(instanceInfo.path);
}
sendHostUpdate() {
this.send(
new lib.HostInfoUpdateEvent(
new lib.HostInfoUpdate(
this.config.get("host.name"),
this.config.get("host.public_address"),
),
),
);
}
/**
* Discover available instances
*