@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.
38 lines (37 loc) • 1.12 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RPCServerClient = void 0;
const client_1 = __importDefault(require("./client"));
const ws_1 = require("ws");
class RPCServerClient extends client_1.default {
constructor(options, { ws, handshake, session }) {
super(options);
this._session = session;
this._handshake = handshake;
this._state = ws_1.OPEN;
this._identity = options.identity;
this._ws = ws;
this._protocol = ws.protocol;
this._attachWebsocket(this._ws);
}
_attachWebsocket(ws) {
this._ws = ws;
ws.on("close", () => {
this._state = 3; // CLOSED
});
// etc.
}
get handshake() {
return this._handshake;
}
get session() {
return this._session;
}
async connect() {
throw new Error("Cannot connect from server to client");
}
}
exports.RPCServerClient = RPCServerClient;