Skip to content

Commit

Permalink
Merge pull request #205 from c-jimenez/fix/localcontroller_dual_rpc_s…
Browse files Browse the repository at this point in the history
…py_notif

[localcontroller] Remove dual notification from IRtc::ISpy interface when LocalController::ChargePointProxy has been instanciated from CentralSystem::ChargePointProxy
  • Loading branch information
c-jimenez authored May 20, 2024
2 parents f8fcb33 + 8f77f58 commit e5c3716
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/centralsystem/chargepoint/ChargePointProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions src/centralsystem/chargepoint/ChargePointProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() */
Expand Down
3 changes: 3 additions & 0 deletions src/localcontroller/chargepoint/ChargePointProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ std::shared_ptr<IChargePointProxy> IChargePointProxy::createFrom(

// Associate both
centralsystem->setChargePointProxy(proxy);

// Unregister old proxy from RPC spy events
cs_proxy->unregisterFromRpcSpy();
}

return proxy;
Expand Down

0 comments on commit e5c3716

Please sign in to comment.