private flushMessageBuffer(): void {
if (this.messageBuffer.size > 0) {
this.messageBuffer.forEach((message) => {
- // TODO: evaluate the need to track performance
- this.wsConnection.send(message);
+ let beginId: string;
+ let commandName: RequestCommand;
const [messageType] = JSON.parse(message) as OutgoingRequest | Response | ErrorResponse;
+ const isRequest = messageType === MessageType.CALL_MESSAGE;
+ if (isRequest) {
+ [, , commandName] = JSON.parse(message) as OutgoingRequest;
+ beginId = PerformanceStatistics.beginMeasure(commandName);
+ }
+ this.wsConnection.send(message);
+ isRequest && PerformanceStatistics.endMeasure(commandName, beginId);
logger.debug(
`${this.logPrefix()} >> Buffered ${OCPPServiceUtils.getMessageTypeString(
messageType
// Check if wsConnection opened
const wsOpened = chargingStation.isWebSocketConnectionOpened() === true;
if (wsOpened) {
- const beginId = PerformanceStatistics.beginMeasure(commandName as string);
+ const beginId = PerformanceStatistics.beginMeasure(commandName);
try {
chargingStation.wsConnection.send(messageToSend);
logger.debug(
);
sendError = true;
}
- PerformanceStatistics.endMeasure(commandName as string, beginId);
+ PerformanceStatistics.endMeasure(commandName, beginId);
}
const wsClosedOrErrored = !wsOpened || sendError === true;
if (wsClosedOrErrored && params.skipBufferingOnError === false) {