Skip to content

Commit

Permalink
Node: Add WorkerDump type
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillan committed Oct 26, 2023
1 parent 4b6a4ee commit 2888abe
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions node/src/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Channel } from './Channel';
import { Router, RouterOptions } from './Router';
import { WebRtcServer, WebRtcServerOptions } from './WebRtcServer';
import { AppData } from './types';
import { generateUUIDv4 } from './utils';
import { generateUUIDv4, parseVector } from './utils';
import { Event } from './fbs/notification';
import * as FbsRequest from './fbs/request';
import * as FbsWorker from './fbs/worker';
Expand Down Expand Up @@ -184,7 +184,7 @@ export type WorkerResourceUsage =
export type WorkerDump =
{
pid : number;
webrtcServerIds : string[];
webRtcServerIds : string[];
routerIds : string[];
channelMessageHandlers :
{
Expand Down Expand Up @@ -581,7 +581,7 @@ export class Worker<WorkerAppData extends AppData = AppData>
/**
* Dump Worker.
*/
async dump(): Promise<any>
async dump(): Promise<WorkerDump>
{
logger.debug('dump()');

Expand All @@ -595,7 +595,7 @@ export class Worker<WorkerAppData extends AppData = AppData>

response.body(dump);

return dump.unpack();
return parseWorkerDumpResponse(dump);
}

/**
Expand Down Expand Up @@ -807,3 +807,19 @@ export class Worker<WorkerAppData extends AppData = AppData>
this.#observer.safeEmit('close');
}
}

export function parseWorkerDumpResponse(
binary: FbsWorker.DumpResponse
): WorkerDump
{
return {
pid : binary.pid()!,
webRtcServerIds : parseVector(binary, 'webRtcServerIds'),
routerIds : parseVector(binary, 'routerIds'),
channelMessageHandlers :
{
channelRequestHandlers : parseVector(binary.channelMessageHandlers()!, 'channelRequestHandlers'),
channelNotificationHandlers : parseVector(binary.channelMessageHandlers()!, 'channelNotificationHandlers')
}
};
}

0 comments on commit 2888abe

Please sign in to comment.