import { IoSocketClient } from "../lib/communication/IoSocketClient"; import { IoSocketServer } from "../lib/communication/IoSocketServer"; import { getLinkedDispatcher } from "../lib/dispatcher/getLinkedDispatcher"; import { nopeDispatcher } from "../lib/dispatcher/nopeDispatcher"; import { exportFunctionToDispatcher } from "../lib/dispatcher/nopeDispatcherDecorators"; import { serviceRegistry } from "../lib/dispatcher/serviceRegistry"; import { generateBenchmarkFunction } from "../modules/funcs/generateBenchmarkFunction"; async function exportedFunc(a: number, b: number, operator: (a: number, b: number) => Promise) { return await operator(a, b) } export const test = exportFunctionToDispatcher(exportedFunc, { uri: 'test' }) export const benchmark = exportFunctionToDispatcher(generateBenchmarkFunction(1000, 'Executed'), { uri: 'benchmark' }) const serverIOSocket = new IoSocketServer(9002); const dispatcher = getLinkedDispatcher({ communicator: serverIOSocket }); const IOSocketClient = new IoSocketClient('ws://localhost:9002'); const local = new nopeDispatcher({ communicator: IOSocketClient }); const serviceReg = new serviceRegistry({ communicator: IOSocketClient }) async function main() { let i = 0; while (i <= 10000) { await local.performCall('benchmark', []); i++; } try { await local.performCall('unkown', []); } catch (e) { console.log('Succes'); console.error(e) } } main().catch(console.error)