mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Add .id shorthand to InstanceInfo
Turn instance.config.get("instance.id") into instance.id.
This commit is contained in:
1 parent
f662437b3f
commit
05e9230e9e
5 files changed
+12
-7
No files matched your search
@@ -187,7 +187,7 @@ class ControlConnection extends BaseConnection {
|
|||||||
let list = [];
|
let list = [];
|
||||||
for (let instance of this._controller.instances.values()) {
|
for (let instance of this._controller.instances.values()) {
|
||||||
list.push({
|
list.push({
|
||||||
id: instance.config.get("instance.id"),
|
id: instance.id,
|
||||||
name: instance.config.get("instance.name"),
|
name: instance.config.get("instance.name"),
|
||||||
assigned_host: instance.config.get("instance.assigned_host"),
|
assigned_host: instance.config.get("instance.assigned_host"),
|
||||||
game_port: instance.game_port || null,
|
game_port: instance.game_port || null,
|
||||||
@@ -204,10 +204,10 @@ class ControlConnection extends BaseConnection {
|
|||||||
instanceUpdated(instance) {
|
instanceUpdated(instance) {
|
||||||
if (
|
if (
|
||||||
this.instanceSubscriptions.all
|
this.instanceSubscriptions.all
|
||||||
|| this.instanceSubscriptions.instance_ids.includes(instance.config.get("instance.id"))
|
|| this.instanceSubscriptions.instance_ids.includes(instance.id)
|
||||||
) {
|
) {
|
||||||
libLink.messages.instanceUpdate.send(this, {
|
libLink.messages.instanceUpdate.send(this, {
|
||||||
id: instance.config.get("instance.id"),
|
id: instance.id,
|
||||||
name: instance.config.get("instance.name"),
|
name: instance.config.get("instance.name"),
|
||||||
assigned_host: instance.config.get("instance.assigned_host"),
|
assigned_host: instance.config.get("instance.assigned_host"),
|
||||||
game_port: instance.game_port || null,
|
game_port: instance.game_port || null,
|
||||||
|
|||||||
@@ -734,7 +734,7 @@ class Controller {
|
|||||||
let connection = this.wsServer.hostConnections.get(hostId);
|
let connection = this.wsServer.hostConnections.get(hostId);
|
||||||
if (connection) {
|
if (connection) {
|
||||||
await libLink.messages.assignInstance.send(connection, {
|
await libLink.messages.assignInstance.send(connection, {
|
||||||
instance_id: instance.config.get("instance.id"),
|
instance_id: instance.id,
|
||||||
serialized_config: instance.config.serialize("host"),
|
serialized_config: instance.config.serialize("host"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class HostConnection extends BaseConnection {
|
|||||||
for (let instance of this._controller.instances.values()) {
|
for (let instance of this._controller.instances.values()) {
|
||||||
if (instance.config.get("instance.assigned_host") === this._id) {
|
if (instance.config.get("instance.assigned_host") === this._id) {
|
||||||
await libLink.messages.assignInstance.send(this, {
|
await libLink.messages.assignInstance.send(this, {
|
||||||
instance_id: instance.config.get("instance.id"),
|
instance_id: instance.id,
|
||||||
serialized_config: instance.config.serialize("host"),
|
serialized_config: instance.config.serialize("host"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ class HostConnection extends BaseConnection {
|
|||||||
// Check if this instance is assigned somewhere else.
|
// Check if this instance is assigned somewhere else.
|
||||||
if (controllerInstance.config.get("instance.assigned_host") !== this._id) {
|
if (controllerInstance.config.get("instance.assigned_host") !== this._id) {
|
||||||
await libLink.messages.unassignInstance.send(this, {
|
await libLink.messages.unassignInstance.send(this, {
|
||||||
instance_id: controllerInstance.config.get("instance.id"),
|
instance_id: controllerInstance.id,
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ class InstanceInfo {
|
|||||||
status: this.status,
|
status: this.status,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Shorthand for `instance.config.get("instance.id")` @type {number} */
|
||||||
|
get id() {
|
||||||
|
return this.config.get("instance.id");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = InstanceInfo;
|
module.exports = InstanceInfo;
|
||||||
@@ -42,7 +42,7 @@ class ControllerPlugin extends libPlugin.BaseControllerPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onInstanceStatusChanged(instance) {
|
async onInstanceStatusChanged(instance) {
|
||||||
let instanceId = instance.config.get("instance.id");
|
let instanceId = instance.id;
|
||||||
if (["unassigned", "deleted"].includes(instance.status)) {
|
if (["unassigned", "deleted"].includes(instance.status)) {
|
||||||
for (let [playerName, acquisitionRecord] of this.acquiredPlayers) {
|
for (let [playerName, acquisitionRecord] of this.acquiredPlayers) {
|
||||||
if (acquisitionRecord.instanceId === instanceId) {
|
if (acquisitionRecord.instanceId === instanceId) {
|
||||||
|
|||||||
Reference in new issue
Block a user