diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CommonAPI/Factory.h | 8 | ||||
-rw-r--r-- | src/CommonAPI/Stub.h | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/CommonAPI/Factory.h b/src/CommonAPI/Factory.h index c07945d..bacda21 100644 --- a/src/CommonAPI/Factory.h +++ b/src/CommonAPI/Factory.h @@ -134,7 +134,13 @@ class Factory { } inline bool unregisterService(const std::string& serviceAddress) { - return registeredServices_.erase(serviceAddress); + auto foundStubAdapter = registeredServices_.find(serviceAddress); + if(foundStubAdapter != registeredServices_.end()) { + std::shared_ptr<CommonAPI::StubAdapter> stubAdapter = foundStubAdapter->second; + stubAdapter->deinit(); + return registeredServices_.erase(serviceAddress); + } + return false; } virtual std::vector<std::string> getAvailableServiceInstances(const std::string& serviceName, const std::string& serviceDomainName = "local") = 0; diff --git a/src/CommonAPI/Stub.h b/src/CommonAPI/Stub.h index 7353f54..740cc7a 100644 --- a/src/CommonAPI/Stub.h +++ b/src/CommonAPI/Stub.h @@ -21,6 +21,8 @@ class StubAdapter { virtual const std::string& getDomain() const = 0; virtual const std::string& getServiceId() const = 0; virtual const std::string& getInstanceId() const = 0; + + virtual void deinit() = 0; }; struct StubBase { @@ -37,6 +39,7 @@ class Stub : public StubBase { virtual ~Stub() { } virtual _StubRemoteEventHandler* initStubAdapter(const std::shared_ptr<_StubAdapter>& stubAdapter) = 0; + virtual void deinitStubAdapter() = 0; }; } // namespace CommonAPI |