mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 07:43:12 +09:00
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:
1 parent
790f880e98
commit
688ddc529b
8 files changed
+94
-42
No files matched your search
@@ -212,23 +212,19 @@ export class RegisterHostData {
|
||||
constructor(
|
||||
public token: string,
|
||||
public version: string,
|
||||
public name: string,
|
||||
public id: number,
|
||||
public publicAddress: string | undefined,
|
||||
public plugins: Record<string, string>,
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"token": Type.String(),
|
||||
"version": Type.String(),
|
||||
"name": Type.String(),
|
||||
"id": Type.Integer(),
|
||||
"publicAddress": Type.Optional(Type.String()),
|
||||
"plugins": Type.Record(Type.String(), Type.String()),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(json.token, json.version, json.name, json.id, json.publicAddress, json.plugins);
|
||||
return new this(json.token, json.version, json.id, json.plugins);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,44 @@ export class HostListRequest {
|
||||
static Response = jsonArray(HostDetails);
|
||||
}
|
||||
|
||||
export class HostInfoUpdate {
|
||||
constructor(
|
||||
public name: string,
|
||||
public publicAddress: string,
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"name": Type.String(),
|
||||
"publicAddress": Type.String(),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(
|
||||
json.name,
|
||||
json.publicAddress,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class HostInfoUpdateEvent {
|
||||
declare ["constructor"]: typeof HostInfoUpdateEvent;
|
||||
static type = "event" as const;
|
||||
static src = "host" as const;
|
||||
static dst = "controller" as const;
|
||||
|
||||
constructor(
|
||||
public update: HostInfoUpdate,
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"update": HostInfoUpdate.jsonSchema,
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(HostInfoUpdate.fromJSON(json.update));
|
||||
}
|
||||
}
|
||||
|
||||
export class HostUpdatesEvent {
|
||||
declare ["constructor"]: typeof HostUpdatesEvent;
|
||||
static type = "event" as const;
|
||||
|
||||
Reference in new issue
Block a user