mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-18 10:06:33 +00:00
80 lines
2.3 KiB
TypeScript
80 lines
2.3 KiB
TypeScript
import { injectable } from '@theia/core/shared/inversify';
|
|
import {
|
|
NotificationServiceServer,
|
|
NotificationServiceClient,
|
|
AttachedBoardsChangeEvent,
|
|
BoardsPackage,
|
|
LibraryPackage,
|
|
Config,
|
|
Sketch,
|
|
} from '../common/protocol';
|
|
|
|
@injectable()
|
|
export class NotificationServiceServerImpl
|
|
implements NotificationServiceServer
|
|
{
|
|
protected readonly clients: NotificationServiceClient[] = [];
|
|
|
|
notifyIndexUpdated(): void {
|
|
this.clients.forEach((client) => client.notifyIndexUpdated());
|
|
}
|
|
|
|
notifyDaemonStarted(port: string): void {
|
|
this.clients.forEach((client) => client.notifyDaemonStarted(port));
|
|
}
|
|
|
|
notifyDaemonStopped(): void {
|
|
this.clients.forEach((client) => client.notifyDaemonStopped());
|
|
}
|
|
|
|
notifyPlatformInstalled(event: { item: BoardsPackage }): void {
|
|
this.clients.forEach((client) => client.notifyPlatformInstalled(event));
|
|
}
|
|
|
|
notifyPlatformUninstalled(event: { item: BoardsPackage }): void {
|
|
this.clients.forEach((client) => client.notifyPlatformUninstalled(event));
|
|
}
|
|
|
|
notifyLibraryInstalled(event: { item: LibraryPackage }): void {
|
|
this.clients.forEach((client) => client.notifyLibraryInstalled(event));
|
|
}
|
|
|
|
notifyLibraryUninstalled(event: { item: LibraryPackage }): void {
|
|
this.clients.forEach((client) => client.notifyLibraryUninstalled(event));
|
|
}
|
|
|
|
notifyAttachedBoardsChanged(event: AttachedBoardsChangeEvent): void {
|
|
this.clients.forEach((client) => client.notifyAttachedBoardsChanged(event));
|
|
}
|
|
|
|
notifyConfigChanged(event: { config: Config | undefined }): void {
|
|
this.clients.forEach((client) => client.notifyConfigChanged(event));
|
|
}
|
|
|
|
notifyRecentSketchesChanged(event: { sketches: Sketch[] }): void {
|
|
this.clients.forEach((client) => client.notifyRecentSketchesChanged(event));
|
|
}
|
|
|
|
setClient(client: NotificationServiceClient): void {
|
|
this.clients.push(client);
|
|
}
|
|
|
|
disposeClient(client: NotificationServiceClient): void {
|
|
const index = this.clients.indexOf(client);
|
|
if (index === -1) {
|
|
console.warn(
|
|
'Could not dispose notification service client. It was not registered.'
|
|
);
|
|
return;
|
|
}
|
|
this.clients.splice(index, 1);
|
|
}
|
|
|
|
dispose(): void {
|
|
for (const client of this.clients) {
|
|
this.disposeClient(client);
|
|
}
|
|
this.clients.length = 0;
|
|
}
|
|
}
|