coretraffic/ts/coretraffic.classes.coreflowconnector.ts

44 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2024-05-15 08:10:41 +00:00
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();
}
}