}
public async messageHandler(request: RawData): Promise<void> {
+ let messageId: string;
let command: ProtocolCommand;
let payload: JsonType;
const protocolRequest = JSON.parse(request.toString()) as ProtocolRequest;
if (Utils.isIterable(protocolRequest)) {
- [command, payload] = protocolRequest;
+ [messageId, command, payload] = protocolRequest;
} else {
throw new BaseError('UI protocol request is not iterable');
}
);
}
// Send the message response
- this.uiServer.sendResponse(this.buildProtocolMessage(command, messageResponse));
+ this.uiServer.sendResponse(this.buildProtocolMessage(messageId, command, messageResponse));
}
- protected buildProtocolMessage(command: ProtocolCommand, payload: JsonType): string {
- return JSON.stringify([command, payload]);
+ protected buildProtocolMessage(
+ messageId: string,
+ command: ProtocolCommand,
+ payload: JsonType
+ ): string {
+ return JSON.stringify([messageId, command, payload]);
}
private handleListChargingStations(): JsonType {
STOP_TRANSACTION = 'stopTransaction',
}
-export type ProtocolRequest = [ProtocolCommand, JsonType];
+export type ProtocolRequest = [string, ProtocolCommand, JsonType];
export type ProtocolRequestHandler = (
payload: JsonType