import type { IMessage } from './message.js'; import type { IMessageConfirmation } from './message-confirmation.js'; import { type OcppRequest, type OcppResponse, MessageState } from '@citrineos/types'; import { OcppError } from '../../ocpp/rpc/message.js'; /** * IMessageSender * * Represents an interface for sending messages. * * All implementations of this interface should carry any context from the {@link IMessage} * to be sent as metadata in the underlying message transport. This will allow to route * messages to the correct module and filter them accordingly. */ export interface IMessageSender { /** * Sends a request message. * * @param message - The message object. * @param payload - The payload object. * @returns A promise that resolves to the message confirmation. */ sendRequest(message: IMessage, payload?: OcppRequest): Promise; /** * Sends a response message. * * @param message - The message object. * @param payload - The payload object. * @returns A promise that resolves to the message confirmation. */ sendResponse(message: IMessage, payload?: OcppResponse | OcppError): Promise; /** * Sends a message. * * @param message - The message object. * @param payload - The payload object. * @param state - The message state. * @returns A promise that resolves to the message confirmation. */ send(message: IMessage, payload?: OcppRequest | OcppResponse | OcppError, state?: MessageState): Promise; /** * Shuts down the sender. */ shutdown(): Promise; }