Skip to content

Commit

Permalink
Allow retrieving ocpp handler
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Sep 14, 2024
1 parent 11a1741 commit 05e0024
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ocppj/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 05e0024

Please sign in to comment.