@citrineos/base
Version:
The base module for OCPP v2.0.1 including all interfaces. This module is not intended to be used directly, but rather as a dependency for other modules.
43 lines (42 loc) • 1.74 kB
TypeScript
import { IMessage, OcppRequest, OcppResponse } from '../..';
import { CallAction } from '../../ocpp/rpc/message';
import { IModule } from '../modules';
import { HandlerProperties } from '.';
/**
* MessageHandler
*
* The interface for all message handlers.
*
*/
export interface IMessageHandler {
/**
* Subscribes to messages based on actions and context filters.
*
* @param identifier - The identifier to subscribe for.
* @param actions - Optional. The list of call actions to subscribe to.
* @param filter - Optional. An additional message context filter. **Note**: Might not be supported by all implementations. @see {@link IMessageContext} for available attributes.
* @returns A promise that resolves to a boolean value indicating whether the initialization was successful.
*/
subscribe(identifier: string, actions?: CallAction[], filter?: {
[k: string]: string;
}): Promise<boolean>;
/**
* Unsubscribe from messages. E.g. when a connection drops.
*
* @param identifier - The identifier to unsubscribe from.
* @returns A promise that resolves to a boolean value indicating whether the unsubscription was successful.
*/
unsubscribe(identifier: string): Promise<boolean>;
/**
* Handles incoming messages.
* @param message - The message to be handled.
* @param props - Optional properties for the handler.
*/
handle(message: IMessage<OcppRequest | OcppResponse>, props?: HandlerProperties): void;
/**
* Shuts down the handler. Unregister all handlers and opening up any resources.
*/
shutdown(): Promise<void>;
get module(): IModule | undefined;
set module(value: IModule | undefined);
}