diff --git a/src/centralsystem/chargepoint/ChargePointProxy.cpp b/src/centralsystem/chargepoint/ChargePointProxy.cpp index fe61281d..56be03be 100644 --- a/src/centralsystem/chargepoint/ChargePointProxy.cpp +++ b/src/centralsystem/chargepoint/ChargePointProxy.cpp @@ -78,6 +78,12 @@ ChargePointProxy::ChargePointProxy(ICentralSystem& /** @brief Destructor */ ChargePointProxy::~ChargePointProxy() +{ + unregisterFromRpcSpy(); +} + +/** @brief Unregister to the IRpc::ISpy interface messages */ +void ChargePointProxy::unregisterFromRpcSpy() { m_rpc->unregisterSpy(*this); } diff --git a/src/centralsystem/chargepoint/ChargePointProxy.h b/src/centralsystem/chargepoint/ChargePointProxy.h index 39ac625a..01ffe5fc 100644 --- a/src/centralsystem/chargepoint/ChargePointProxy.h +++ b/src/centralsystem/chargepoint/ChargePointProxy.h @@ -58,6 +58,9 @@ class ChargePointProxy : public ICentralSystem::IChargePoint, public ocpp::rpc:: /** @brief Destructor */ virtual ~ChargePointProxy(); + /** @brief Unregister to the IRpc::ISpy interface messages */ + void unregisterFromRpcSpy(); + // ICentralSystem::IChargePoint interface /** @copydoc ICentralSystem&& ICentralSystem::IChargePoint::centralSystem() */ diff --git a/src/localcontroller/chargepoint/ChargePointProxy.cpp b/src/localcontroller/chargepoint/ChargePointProxy.cpp index f45ee90f..f87a4c27 100644 --- a/src/localcontroller/chargepoint/ChargePointProxy.cpp +++ b/src/localcontroller/chargepoint/ChargePointProxy.cpp @@ -56,6 +56,9 @@ std::shared_ptr IChargePointProxy::createFrom( // Associate both centralsystem->setChargePointProxy(proxy); + + // Unregister old proxy from RPC spy events + cs_proxy->unregisterFromRpcSpy(); } return proxy;