coretraffic/ts/coretraffic.classes.coreflowconnector.ts
2024-05-15 10:10:41 +02:00

44 lines
1.3 KiB
TypeScript

import * as plugins from './coretraffic.plugins.js';
import { logger } from './coretraffic.logging.js';
import { CoreTraffic } from './coretraffic.classes.coretraffic.js';
/**
* Coreflow Connector
*/
export class CoreflowConnector {
public typedrouter = new plugins.typedrequest.TypedRouter();
public coretrafficRef: CoreTraffic;
public typesocketClient: plugins.typedsocket.TypedSocket;
constructor(coretrafficRefArg: CoreTraffic) {
this.coretrafficRef = coretrafficRefArg;
this.coretrafficRef.typedrouter.addTypedRouter(this.typedrouter)
this.typedrouter.addTypedHandler<
plugins.lointCloudly.request.routing.IRequest_Coreflow_Coretraffic_RoutingUpdate
>(new plugins.typedrequest.TypedHandler('updateRouting', async (requestData) => {
console.log(requestData);
await this.coretrafficRef.taskmanager.setupRoutingTask.trigger(requestData.reverseConfigs);
return {
status: 'ok',
errorText: ''
};
}));
}
/**
* starts the corechatConnector
*/
public async start() {
this.typesocketClient = await plugins.typedsocket.TypedSocket.createClient(
this.typedrouter,
'http://coreflow:3000',
'coretraffic'
);
}
public async stop() {
await this.typesocketClient.stop();
}
}