Skip to content

Commit c490292

Browse files
committed
Include service parameters and spec in manifest and state meta.
This upstreams functionality used in the ACO and RaceResults.ru clients (and should be common to all services that use the parameter functionality).
1 parent 4347491 commit c490292

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/services/services.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,21 @@ export class Service extends EventEmitter {
8080
newState.lastUpdated = Date.now();
8181
delete newState.extraMessages;
8282

83+
if (this.parameters && this.constructor.parametersSpec) {
84+
if (!newState.meta) {
85+
newState.meta = {};
86+
}
87+
newState.meta.parameters = this.parameters;
88+
}
89+
8390
this.emit(Events.STATE_CHANGE, newState);
8491
this._prevState = newState;
8592
}
8693

8794
/**
88-
* Adds start time and UUID to the manifest, and if a deep equality check
89-
* fails, emits an event with the new manifest then updates our state.
95+
* Adds start time, UUID and parameters (if appropriate) to the manifest, and
96+
* if a deep equality check fails, emits an event with the new manifest then
97+
* updates our state.
9098
*/
9199
onManifestChange(newManifest) {
92100
const newManifestWithStartTime = {
@@ -95,6 +103,10 @@ export class Service extends EventEmitter {
95103
uuid: this.service.uuid
96104
};
97105

106+
if (this.constructor.parametersSpec) {
107+
newManifestWithStartTime.parameters = this.constructor.parametersSpec;
108+
}
109+
98110
if (!deepEqual(newManifestWithStartTime, this._prevState.manifest)) {
99111
this.emit(Events.MANIFEST_CHANGE, newManifestWithStartTime);
100112
this.onStateChange({ manifest: newManifestWithStartTime });

0 commit comments

Comments
 (0)