UNPKG

@citrineos/ocpprouter

Version:

The ocpprouter module for OCPP v2.0.1. This module is not intended to be used directly, but rather as a dependency for other modules.

44 lines (43 loc) 2.35 kB
import { OCPPVersionType } from '@citrineos/base'; import { ISubscriptionRepository } from '@citrineos/data'; import { ILogObj, Logger } from 'tslog'; export declare class WebhookDispatcher { private static readonly SUBSCRIPTION_REFRESH_INTERVAL_MS; private _logger; private _subscriptionRepository; private _identifiers; private _onConnectionCallbacks; private _onCloseCallbacks; private _onMessageCallbacks; private _sentMessageCallbacks; constructor(subscriptionRepository: ISubscriptionRepository, logger?: Logger<ILogObj>); register(identifier: string): Promise<void>; deregister(identifier: string): Promise<void>; protected _dispatchMessageReceivedUnparsed(identifier: string, message: string, timestamp: string, protocol: OCPPVersionType): Promise<void>; dispatchMessageReceived(identifier: string, message: string, timestamp: string, protocol: OCPPVersionType, rpcMessage?: any): Promise<void>; dispatchMessageSent(identifier: string, message: string, timestamp: string, protocol: OCPPVersionType, rpcMessage: any): Promise<void>; private _refreshSubscriptions; /** * Loads all subscriptions for a given connection into memory * * @param {string} connectionIdentifier - the identifier of the connection * @return {Promise<void>} a promise that resolves once all subscriptions are loaded */ private _loadSubscriptionsForConnection; private _onConnectionCallback; private _onCloseCallback; private _onMessageReceivedCallback; private _onMessageSentCallback; /** * Sends a message to a given URL that has been subscribed to a station connection event * * @param {Object} requestBody - request body containing stationId, event, origin, message, error, and info * @param {string} url - the URL to fetch data from * @return {Promise<boolean>} a Promise that resolves to a boolean indicating success */ private _subscriptionCallback; } export type OnConnectionCallback = (info?: Map<string, string>) => Promise<boolean>; export type OnCloseCallback = (info?: Map<string, string>) => Promise<boolean>; export type OnMessageCallback = (message: string, info?: Map<string, string>) => Promise<boolean>; export type OnSentMessageCallback = (message: string, info?: Map<string, string>) => Promise<boolean>;