- MessageType.CALL_RESULT_MESSAGE
- );
- }
- // Handle the request's response
- self.ocppResponseService
- .responseHandler(
- chargingStation,
- commandName as RequestCommand,
- payload,
- requestPayload
+ (messagePayload as OCPPError).details
+ )
+ )
+ }, OCPPConstants.OCPP_WEBSOCKET_TIMEOUT)
+ chargingStation.wsConnection?.send(messageToSend, (error?: Error) => {
+ PerformanceStatistics.endMeasure(commandName, beginId)
+ clearTimeout(sendTimeout)
+ if (error == null) {
+ logger.debug(
+ `${chargingStation.logPrefix()} >> Command '${commandName}' sent ${OCPPServiceUtils.getMessageTypeString(
+ messageType
+ )} payload: ${messageToSend}`
+ )
+ if (messageType === MessageType.CALL_MESSAGE) {
+ this.setCachedRequest(
+ chargingStation,
+ messageId,
+ messagePayload as JsonType,
+ commandName,
+ responseCallback,
+ errorCallback
+ )
+ } else {
+ // Resolve response
+ resolve(messagePayload)
+ }
+ } else {
+ handleSendError(
+ new OCPPError(
+ ErrorType.GENERIC_ERROR,
+ `WebSocket errored for ${
+ params?.skipBufferingOnError === false ? '' : 'non '
+ }buffered message id '${messageId}' with content '${messageToSend}'`,
+ commandName,
+ { name: error.name, message: error.message, stack: error.stack }
+ )