Skip to content

Commit 5035b0b

Browse files
author
Alberto Iannaccone
committed
refactor monitor commands protocol
1 parent 9ea51b2 commit 5035b0b

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

arduino-ide-extension/src/browser/monitor-manager-proxy-client-impl.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class MonitorManagerProxyClientImpl
111111

112112
this.webSocket.send(
113113
JSON.stringify({
114-
command: Monitor.Command.SEND_MESSAGE,
114+
command: Monitor.ClientCommand.SEND_MESSAGE,
115115
data: message,
116116
})
117117
);
@@ -124,9 +124,7 @@ export class MonitorManagerProxyClientImpl
124124

125125
this.webSocket.send(
126126
JSON.stringify({
127-
command: Monitor.Command.CHANGE_SETTINGS,
128-
// TODO: This might be wrong, verify if it works
129-
// SPOILER: It doesn't
127+
command: Monitor.ClientCommand.CHANGE_SETTINGS,
130128
data: settings,
131129
})
132130
);

arduino-ide-extension/src/common/protocol/monitor-service.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,18 @@ export interface PluggableMonitorSetting {
5959
}
6060

6161
export namespace Monitor {
62-
export enum Command {
63-
SEND_MESSAGE = 'MONITOR_SEND_MESSAGE',
64-
CHANGE_SETTINGS = 'MONITOR_CHANGE_SETTINGS',
62+
// Commands sent by the clients to the web socket server
63+
export enum ClientCommand {
64+
SEND_MESSAGE = 'SEND_MESSAGE',
65+
CHANGE_SETTINGS = 'CHANGE_SETTINGS',
66+
}
67+
68+
export enum MiddlewareCommand {
69+
ON_SETTINGS_DID_CHANGE = 'ON_SETTINGS_DID_CHANGE',
6570
}
6671

6772
export type Message = {
68-
command: Monitor.Command;
73+
command: Monitor.ClientCommand;
6974
data: string | MonitorSettings;
7075
};
7176
}

arduino-ide-extension/src/node/monitor-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ export class MonitorService extends CoreClientAware implements Disposable {
419419
const message: Monitor.Message = JSON.parse(msg);
420420

421421
switch (message.command) {
422-
case Monitor.Command.SEND_MESSAGE:
422+
case Monitor.ClientCommand.SEND_MESSAGE:
423423
this.send(message.data as string);
424424
break;
425-
case Monitor.Command.CHANGE_SETTINGS:
425+
case Monitor.ClientCommand.CHANGE_SETTINGS:
426426
this.changeSettings(message.data as MonitorSettings);
427427
break;
428428
}

0 commit comments

Comments
 (0)