Fixed missing core client in the monitor service.

Restored monitor service creation state before a36524e:
Pass core client provider into new instances as a field.

Closes #1161

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2022-07-10 07:34:58 +02:00 committed by Akos Kitta
parent 7d961537eb
commit f4a68e793e
5 changed files with 15 additions and 5 deletions

View File

@ -245,7 +245,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
const webSocketProvider =
container.get<WebSocketProvider>(WebSocketProvider);
const { board, port, monitorID } = options;
const { board, port, coreClientProvider, monitorID } = options;
return new MonitorService(
logger,
@ -253,6 +253,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
webSocketProvider,
board,
port,
coreClientProvider,
monitorID
);
}

View File

@ -397,7 +397,7 @@ export namespace CoreClientProvider {
@injectable()
export abstract class CoreClientAware {
@inject(CoreClientProvider)
private readonly coreClientProvider: CoreClientProvider;
protected readonly coreClientProvider: CoreClientProvider; // TODO: should be `private`, fix injection in subclasses. (https://github.com/arduino/arduino-ide/issues/1161)
/**
* Returns with a promise that resolves when the core client is initialized and ready.
*/

View File

@ -55,7 +55,7 @@ export class MonitorManager extends CoreClientAware {
* @param board board connected to port
* @param port port to monitor
* @returns true if the monitor is currently monitoring the board/port
* combination specifed, false in all other cases.
* combination specified, false in all other cases.
*/
isStarted(board: Board, port: Port): boolean {
const monitorID = this.monitorID(board, port);
@ -317,6 +317,7 @@ export class MonitorManager extends CoreClientAware {
board,
port,
monitorID,
coreClientProvider: this.coreClientProvider,
});
this.monitorServices.set(monitorID, monitor);
monitor.onDispose(

View File

@ -1,13 +1,20 @@
import { Board, Port } from '../common/protocol';
import { CoreClientProvider } from './core-client-provider';
import { MonitorService } from './monitor-service';
export const MonitorServiceFactory = Symbol('MonitorServiceFactory');
export interface MonitorServiceFactory {
(options: { board: Board; port: Port; monitorID: string }): MonitorService;
(options: {
board: Board;
port: Port;
monitorID: string;
coreClientProvider: CoreClientProvider;
}): MonitorService;
}
export interface MonitorServiceFactoryOptions {
board: Board;
port: Port;
monitorID: string;
coreClientProvider: CoreClientProvider;
}

View File

@ -10,7 +10,7 @@ import {
MonitorRequest,
MonitorResponse,
} from './cli-protocol/cc/arduino/cli/commands/v1/monitor_pb';
import { CoreClientAware } from './core-client-provider';
import { CoreClientAware, CoreClientProvider } from './core-client-provider';
import { WebSocketProvider } from './web-socket/web-socket-provider';
import { Port as gRPCPort } from 'arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/port_pb';
import {
@ -77,6 +77,7 @@ export class MonitorService extends CoreClientAware implements Disposable {
private readonly board: Board,
private readonly port: Port,
protected override readonly coreClientProvider: CoreClientProvider,
private readonly monitorID: string
) {
super();