mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 15:43:13 +09:00
Add instance update subscription
Provide the control link with the ability to subscribe to updates when instance status and properties changes. This allows the web interface to respond in real time to instance starts and stops that are triggered from somewhere else.
This commit is contained in:
1 parent
bda103d7a0
commit
6ffcb8c451
11 files changed
+219
-29
No files matched your search
@@ -152,7 +152,7 @@ class Master {
|
||||
await this.userManager.load(path.join(databaseDirectory, "users.json"));
|
||||
|
||||
for (let instance of this.instances.values()) {
|
||||
this.addInstancePluginHooks(instance);
|
||||
this.addInstanceHooks(instance);
|
||||
}
|
||||
|
||||
// Make sure we're actually going to listen on a port
|
||||
@@ -361,10 +361,26 @@ class Master {
|
||||
}
|
||||
}
|
||||
|
||||
addInstancePluginHooks(instance) {
|
||||
addInstanceHooks(instance) {
|
||||
instance.config.on("fieldChanged", (group, field, prev) => {
|
||||
if (group.name === "instance" && field === "name") {
|
||||
this.instanceUpdated(instance);
|
||||
}
|
||||
|
||||
libPlugin.invokeHook(this.plugins, "onInstanceConfigFieldChanged", instance, group, field, prev);
|
||||
});
|
||||
|
||||
this.instanceUpdated(instance);
|
||||
}
|
||||
|
||||
instanceUpdated(instance) {
|
||||
for (let controlConnection of this.wsServer.controlConnections) {
|
||||
if (controlConnection.connector.closing) {
|
||||
continue;
|
||||
}
|
||||
|
||||
controlConnection.instanceUpdated(instance);
|
||||
}
|
||||
}
|
||||
|
||||
async loadPlugins() {
|
||||
|
||||
Reference in new issue
Block a user