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

+1 -5
View File
@@ -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);
}
}
+38
View File
@@ -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;