this.uiServiceWorkerBroadcastChannel = new UIServiceWorkerBroadcastChannel(this);
}
- public async requestHandler(request: RawData): Promise<void> {
+ public async requestHandler(request: RawData | JsonType): Promise<void> {
let messageId: string;
let command: ProcedureName;
let requestPayload: RequestPayload | undefined;
responsePayload = await this.requestHandlers.get(command)(messageId, requestPayload);
} catch (error) {
// Log
- logger.error(
- `${this.uiServer.logPrefix(moduleName, 'messageHandler')} Handle request error:`,
- error
- );
+ logger.error(`${this.logPrefix(moduleName, 'messageHandler')} Handle request error:`, error);
responsePayload = {
status: ResponseStatus.FAILURE,
command,
if (responsePayload !== undefined) {
// Send the response
- this.uiServer.sendResponse(this.buildProtocolResponse(messageId ?? 'error', responsePayload));
+ this.sendResponse(messageId ?? 'error', responsePayload);
}
}
// Validate the raw data received from the WebSocket
// TODO: should probably be moved to the ws verify clients callback
- private requestValidation(rawData: RawData): ProtocolRequest {
+ private requestValidation(rawData: RawData | JsonType): ProtocolRequest {
// logger.debug(
- // `${this.uiServer.logPrefix(
+ // `${this.logPrefix(
// moduleName,
- // 'dataValidation'
- // )} Raw data received: ${rawData.toString()}`
+ // 'requestValidation'
+ // )} Data received in string format: ${rawData.toString()}`
// );
const data = JSON.parse(rawData.toString()) as JsonType[];