Adds a hook for client and servers to support custom handling of incoming invalid messages.
This refers to invalid payloads only:
if the message is malformed, the hook won't be invoked
if the payload is not conform to the specified feature name, the hook will be invoked
The hooks are completely optional and may be set as follows:
// Client
ocppjClient.SetInvalidMessageHook(func(err *ocpp.Error, rawMessage string, parsedFields []interface{}) *ocpp.Error {
// custom handling
return ocpp.NewError(...) // if no error override is necessary, nil can be returned
})
// Server
ocppjServer.SetInvalidMessageHook(func(client ws.Channel, err *ocpp.Error, rawMessage string, parsedFields []interface{}) *ocpp.Error {
// custom handling
return ocpp.NewError(...) // if no error override is necessary, nil can be returned
}
If set, a hook MUST return a value as soon as possible, as the function call blocks the main routine from receiving any other messages.
If the returned value is nil the internal error will be sent back to the other endpoint.
If the returned value is actually a valid error, it will be sent back to the other endpoint instead of the internally generated error.
Adds a hook for client and servers to support custom handling of incoming invalid messages.
This refers to invalid payloads only:
The hooks are completely optional and may be set as follows:
If set, a hook MUST return a value as soon as possible, as the function call blocks the main routine from receiving any other messages.
If the returned value is
nil
the internal error will be sent back to the other endpoint. If the returned value is actually a valid error, it will be sent back to the other endpoint instead of the internally generated error.Addresses the issue described here.