Implement processor attaching and detaching

This commit is contained in:
David Majdandžić
2023-04-05 17:52:44 +02:00
parent 2628445422
commit 6dbb108c2b
4 changed files with 82 additions and 36 deletions

View File

@@ -3,6 +3,7 @@ import CenterSessionManager from "./Center/CenterSessionManager";
import Client from "./Client/Client";
import ClientSessionManager from "./Client/ClientSessionManager";
import Logger from "./Logger";
import SourceEnumeratorProcessor from "./PDUProcessor/Preprocessor/Client/SourceEnumeratorProcessor";
import ProcessorManager from "./PDUProcessor/ProcessorManager";
import WSServer from "./WS/WSServer";
@@ -17,6 +18,7 @@ let centerManager: CenterSessionManager = new CenterSessionManager();
// TODO: Fix reading and writing processors
// TODO: Try creating multiple entries with the same arg
let wss: WSServer = new WSServer([clientManager, centerManager]);
// let httpServer: HttpServer = new HttpServer(clientManager, centerManager);
function cleanup(): void {
@@ -28,23 +30,24 @@ function cleanup(): void {
async function main() {
let client: Client = await clientManager.getSession(0) as Client
let center: Center = await centerManager.getSession(0) as Center;
setInterval(async () => {
await client.doConnect();
setTimeout(async () => {
await client.doBind();
setTimeout(async () => {
await center.close();
}, 1000);
}, 1000);
}, 3000);
// let center: Center = await centerManager.getSession(0) as Center;
// setInterval(async () => {
// await client.doConnect();
// setTimeout(async () => {
// await client.doBind();
// setTimeout(async () => {
// await center.close();
// }, 1000);
// }, 1000);
// }, 3000);
console.log(ProcessorManager.getProcessorsForType(Client.name));
ProcessorManager.attachProcessor(client, ProcessorManager.getProcessor(SourceEnumeratorProcessor.name));
console.log("OK");
}
// main();
console.log(ProcessorManager);
// console.log(ProcessorManager.getProcessorsForType(Center.name));
// console.log(ProcessorManager.processors);
console.log("OK");
main();
// process.on('exit', cleanup);
// process.on('SIGINT', cleanup);