* @param payload
* @param requestPayload
*/
- async function responseCallback(
- payload: JsonType,
- requestPayload: JsonType
- ): Promise<void> {
+ function responseCallback(payload: JsonType, requestPayload: JsonType): void {
if (chargingStation.getEnableStatistics() === true) {
chargingStation.performanceStatistics.addRequestStatistic(
commandName,
);
}
// Handle the request's response
- try {
- await self.ocppResponseService.responseHandler(
+ self.ocppResponseService
+ .responseHandler(
chargingStation,
commandName as RequestCommand,
payload,
requestPayload
- );
- resolve(payload);
- } catch (error) {
- reject(error);
- } finally {
- chargingStation.requests.delete(messageId);
- }
+ )
+ .then(() => {
+ resolve(payload);
+ })
+ .catch((error) => {
+ reject(error);
+ })
+ .finally(() => {
+ chargingStation.requests.delete(messageId);
+ });
}
/**
messagePayload: JsonType | OCPPError,
messageType: MessageType,
commandName?: RequestCommand | IncomingRequestCommand,
- responseCallback?: (payload: JsonType, requestPayload: JsonType) => Promise<void>,
+ responseCallback?: (payload: JsonType, requestPayload: JsonType) => void,
errorCallback?: (error: OCPPError, requestStatistic?: boolean) => void
): string {
let messageToSend: string;