Skip to content

Commit 0b56e33

Browse files
committed
split telemetry messages
1 parent 7e79f03 commit 0b56e33

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

src/api-monitor-cs-main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const tick = new Timer(
3535

3636
if (delta) {
3737
windowPost({
38-
msg: EMsg.TELEMETRY,
38+
msg: EMsg.TELEMETRY_DELTA,
3939
timeOfCollection: now,
4040
telemetryDelta: delta,
4141
});

src/api/communication.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export enum EMsg {
9696
START_OBSERVE,
9797
STOP_OBSERVE,
9898
TELEMETRY,
99+
TELEMETRY_DELTA,
99100
TELEMETRY_ACKNOWLEDGED,
100101
MEDIA_COMMAND,
101102
RESET_WRAPPER_HISTORY,
@@ -122,8 +123,12 @@ export interface TMsgLoaded {
122123
export interface TMsgTelemetry {
123124
msg: EMsg.TELEMETRY;
124125
timeOfCollection: number;
125-
telemetry?: TTelemetry;
126-
telemetryDelta?: Delta;
126+
telemetry: TTelemetry;
127+
}
128+
export interface TMsgTelemetryDelta {
129+
msg: EMsg.TELEMETRY_DELTA;
130+
timeOfCollection: number;
131+
telemetryDelta: Delta;
127132
}
128133
export interface TMsgTelemetryAcknowledged {
129134
msg: EMsg.TELEMETRY_ACKNOWLEDGED;
@@ -141,6 +146,7 @@ export interface TMsgMediaCommand {
141146
}
142147
export type TMsgOptions =
143148
| TMsgTelemetry
149+
| TMsgTelemetryDelta
144150
| TMsgTelemetryAcknowledged
145151
| TMsgStartObserve
146152
| TMsgStopObserve

src/view/App.svelte

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,13 @@
3232
}
3333
});
3434
} else if (o.msg === EMsg.TELEMETRY) {
35-
if (o.telemetry) {
36-
telemetryProgressive = structuredClone(o.telemetry);
37-
telemetry = o.telemetry;
38-
} else if (o.telemetryDelta) {
39-
diff.patch(telemetryProgressive, o.telemetryDelta);
40-
telemetry = structuredClone(telemetryProgressive);
41-
}
42-
43-
portPost({
44-
msg: EMsg.TELEMETRY_ACKNOWLEDGED,
45-
timeOfCollection: o.timeOfCollection,
46-
});
47-
48-
spinnerEl?.tick();
35+
telemetryProgressive = structuredClone(o.telemetry);
36+
telemetry = o.telemetry;
37+
acknowledgeTelemetry(o.timeOfCollection);
38+
} else if (o.msg === EMsg.TELEMETRY_DELTA) {
39+
diff.patch(telemetryProgressive, o.telemetryDelta);
40+
telemetry = structuredClone(telemetryProgressive);
41+
acknowledgeTelemetry(o.timeOfCollection);
4942
}
5043
});
5144
@@ -59,6 +52,15 @@
5952
});
6053
});
6154
55+
function acknowledgeTelemetry(timeOfCollection: number) {
56+
portPost({
57+
msg: EMsg.TELEMETRY_ACKNOWLEDGED,
58+
timeOfCollection,
59+
});
60+
61+
spinnerEl?.tick();
62+
}
63+
6264
function onTogglePause() {
6365
paused = !paused;
6466
setSettings({ paused });

0 commit comments

Comments
 (0)