@openevstack/ocpp-rpc
Version:
⚡ A lightweight, production-ready RPC server built with Express and WebSocket for handling OCPP-based EV charger communication. Part of the OpenEVStack ecosystem.
66 lines (65 loc) • 1.64 kB
TypeScript
import { WebSocket } from "ws";
import { Validator } from "../utils/validator";
import { Protocol } from "../enums/protocol.enum";
export interface ClientOptions {
identity?: string;
endpoint?: string;
password?: string;
query?: string;
callTimeoutMs: number;
pingIntervalMs: number;
deferPingsOnActivity: boolean;
wsOpts?: WsOpts | {};
headers?: {};
protocols: string[];
reconnect?: boolean;
maxReconnects?: number;
respondWithDetailedErrors?: boolean;
callConcurrency?: number;
maxBadMessages?: number;
strictMode?: boolean;
strictModeValidators: Validator[];
backoff?: BackOff;
}
export interface BackOff {
initalDelay: number;
maxDelay: number;
factor: number;
randomisationFactor: number;
}
export interface WsOpts {
noDelay: boolean;
signal: any;
headers: Record<string, string>;
}
export interface ServerOptions {
wssOptions: WsOpts | {};
protocols: Protocol[];
callTimeoutMs: number;
pingIntervalMs: number;
deferPingsOnActivity: boolean;
respondWithDetailedErrors: boolean;
callConcurrency: number;
maxBadMessages: number;
strictMode: boolean;
strictModeValidators: Validator[];
}
export interface IClose {
code: number;
reason: string;
awaitPending?: boolean;
force?: boolean;
options?: ICloseOptions;
}
export interface ICloseOptions {
}
export interface PendingUpgrade {
session?: Record<string, any>;
protocol?: string;
handshake?: any;
}
export interface ServerClientOptions {
ws: WebSocket;
session?: Record<string, any>;
handshake?: any;
}