@citrineos/util
Version:
The OCPP util module which supplies helpful utilities like cache and queue connectors, etc.
62 lines (61 loc) • 3.01 kB
TypeScript
import type { IMessage, IMessageConfirmation, IMessageSender, OcppRequest, OcppResponse } from '@citrineos/base';
import { AbstractMessageSender, MessageState, OcppError } from '@citrineos/base';
import type { ILogObj } from 'tslog';
import { Logger } from 'tslog';
import { RabbitMQChannelManager } from './ChannelManager.js';
import { RabbitMQConnectionManager } from './ConnectionManager.js';
/**
* Implementation of a {@link IMessageSender} using RabbitMQ as the underlying transport.
*/
export declare class RabbitMqSender extends AbstractMessageSender implements IMessageSender {
private exchange;
/**
* Constants
*/
private static readonly CHANNEL_ID;
/**
* Fields
*/
protected _connectionManager: RabbitMQConnectionManager;
protected _channelManager: RabbitMQChannelManager;
/**
* Constructor for the class.
*
* @param {Logger<ILogObj>} [logger] - The logger object.
*/
constructor(exchange: string, connectionManager: RabbitMQConnectionManager, channelManager: RabbitMQChannelManager, logger?: Logger<ILogObj>);
/**
* Methods
*/
/**
* Sends a request message with an optional payload and returns a promise that resolves to the confirmation message.
*
* @param {IMessage<OcppRequest>} message - The message to be sent.
* @param {OcppRequest | undefined} payload - The optional payload to be sent with the message.
* @return {Promise<IMessageConfirmation>} A promise that resolves to the confirmation message.
*/
sendRequest(message: IMessage<OcppRequest>, payload?: OcppRequest | undefined): Promise<IMessageConfirmation>;
/**
* Sends a response message and returns a promise of the message confirmation.
*
* @param {IMessage<OcppResponse | OcppError>} message - The message to send.
* @param {OcppResponse | OcppError} payload - The payload to include in the response.
* @return {Promise<IMessageConfirmation>} - A promise that resolves to the message confirmation.
*/
sendResponse(message: IMessage<OcppResponse | OcppError>, payload?: OcppResponse | OcppError): Promise<IMessageConfirmation>;
/**
* Sends a message and returns a promise that resolves to a message confirmation.
*
* @param {IMessage<OcppRequest | OcppResponse | OcppError>} message - The message to be sent.
* @param {OcppRequest | OcppResponse | OcppError} [payload] - The payload to be included in the message.
* @param {MessageState} [state] - The state of the message.
* @return {Promise<IMessageConfirmation>} - A promise that resolves to a message confirmation.
*/
send(message: IMessage<OcppRequest | OcppResponse | OcppError>, payload?: OcppRequest | OcppResponse | OcppError, state?: MessageState): Promise<IMessageConfirmation>;
/**
* Shuts down the sender by closing the client.
*
* @return {Promise<void>} A promise that resolves when the client is closed.
*/
shutdown(): Promise<void>;
}