From 05e0024dae15abdf97c2876ea97098687cd56239 Mon Sep 17 00:00:00 2001 From: andig Date: Sat, 14 Sep 2024 14:24:23 +0200 Subject: [PATCH] Allow retrieving ocpp handler --- ocppj/client.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ocppj/client.go b/ocppj/client.go index 731fb540..496bbc91 100644 --- a/ocppj/client.go +++ b/ocppj/client.go @@ -54,16 +54,31 @@ func NewClient(id string, wsClient ws.WsClient, dispatcher ClientDispatcher, sta return &Client{Endpoint: endpoint, client: wsClient, Id: id, dispatcher: dispatcher, RequestState: stateHandler} } +// Return incoming requests handler. +func (c *Client) GetRequestHandler() func(request ocpp.Request, requestId string, action string) { + return c.requestHandler +} + // Registers a handler for incoming requests. func (c *Client) SetRequestHandler(handler func(request ocpp.Request, requestId string, action string)) { c.requestHandler = handler } +// Return incoming responses handler. +func (c *Client) GetResponseHandler() func(response ocpp.Response, requestId string) { + return c.responseHandler +} + // Registers a handler for incoming responses. func (c *Client) SetResponseHandler(handler func(response ocpp.Response, requestId string)) { c.responseHandler = handler } +// Return incoming error messages handler. +func (c *Client) GetErrorHandler() func(err *ocpp.Error, details interface{}) { + return c.errorHandler +} + // Registers a handler for incoming error messages. func (c *Client) SetErrorHandler(handler func(err *ocpp.Error, details interface{})) { c.errorHandler = handler