-import { ProtocolCommand, ProtocolRequestHandler } from '../../types/UiProtocol';
+import { ProtocolCommand, ProtocolRequestHandler } from '../../types/UIProtocol';
import BaseError from '../../exception/BaseError';
+import { JsonType } from '../../types/JsonType';
import UIWebSocketServer from '../UIWebSocketServer';
import logger from '../../utils/Logger';
]);
}
- public async handleMessage(command: ProtocolCommand, payload: Record<string, unknown>): Promise<void> {
- let messageResponse: Record<string, unknown>;
+ public async handleMessage(command: ProtocolCommand, payload: JsonType): Promise<void> {
+ let messageResponse: JsonType;
if (this.messageHandlers.has(command)) {
try {
// Call the method to build the message response
- messageResponse = await this.messageHandlers.get(command)(payload) as Record<string, unknown>;
+ messageResponse = await this.messageHandlers.get(command)(payload) as JsonType;
} catch (error) {
// Log
logger.error(this.uiWebSocketServer.logPrefix() + ' Handle message error: %j', error);
protected buildProtocolMessage(
command: ProtocolCommand,
- payload: Record<string, unknown>,
+ payload: JsonType,
): string {
return JSON.stringify([command, payload]);
}