refactor(service): integrate Service Worker Controller initialization into Services class, enhancing service setup and clarity
This commit is contained in:
parent
0ae251a1bd
commit
633fd57793
@ -13,6 +13,7 @@ import { BackUp } from "../types/index";
|
||||
import { APP_CONFIG } from "../config/constants";
|
||||
import { NetworkService } from "./core/network.service";
|
||||
import type { CoreBackend } from "../workers/core.worker";
|
||||
import { SWController } from "./sw-controller.service";
|
||||
import Database from "./database.service";
|
||||
|
||||
export default class Services {
|
||||
@ -55,21 +56,27 @@ export default class Services {
|
||||
|
||||
// 1. Initialiser le Core Worker
|
||||
await this.coreWorker.init();
|
||||
// 2. Initialiser la Database ici (Main Thread) pour lancer le SW
|
||||
|
||||
// 2. Initialiser la Database (Main Thread)
|
||||
await Database.getInstance();
|
||||
// 3. Configurer les Callbacks (Le worker pilote le main thread pour le réseau)
|
||||
|
||||
// 3. Initialiser le Service Worker Controller
|
||||
const swController = await SWController.getInstance();
|
||||
await swController.init();
|
||||
|
||||
// 4. Configurer les Callbacks
|
||||
await this.coreWorker.setCallbacks(
|
||||
Comlink.proxy(this.handleWorkerNotification.bind(this)), // notifier
|
||||
Comlink.proxy(this.handleWorkerNetworkSend.bind(this)), // networkSender
|
||||
Comlink.proxy(this.handleWorkerRelayUpdate.bind(this)), // relayUpdater
|
||||
Comlink.proxy(this.handleWorkerRelayRequest.bind(this)) // relayGetter
|
||||
Comlink.proxy(this.handleWorkerNotification.bind(this)),
|
||||
Comlink.proxy(this.handleWorkerNetworkSend.bind(this)),
|
||||
Comlink.proxy(this.handleWorkerRelayUpdate.bind(this)),
|
||||
Comlink.proxy(this.handleWorkerRelayRequest.bind(this))
|
||||
);
|
||||
|
||||
// 3. Initialiser le Réseau (Network Worker via Proxy)
|
||||
// 5. Initialiser le Réseau
|
||||
await this.networkService.initRelays();
|
||||
|
||||
console.log(
|
||||
"[Services] ✅ Proxy connecté au CoreWorker et NetworkService."
|
||||
"[Services] ✅ Proxy connecté au CoreWorker, SWController et NetworkService."
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user