COVESA / capicxx-core-tools

Common API C++ core tools
Mozilla Public License 2.0
135 stars 106 forks source link

how to unregister proxy, service in c++? #55

Closed mungyujeong closed 1 year ago

mungyujeong commented 1 year ago

Hi, I want to unregister proxy and service. I'm implementing an application where the user can select and run a service and a client. When user changes the mode (service/client), I guess that it should terminate remaining proxy or service in c++. This is what I done before. I put nullptr in myProxy and myService. Proxy was unregistered well as I expected, but service didn't. So I use runtime->unregisterService but it returned false. That's mean failed to deregistering service.

Conclusion: Is there any solution to unregister exisiting service or proxy?

mungyujeong commented 1 year ago

I solve this issue via unregisterService method.

void Simulator::closeService()
{
    auto serviceAddress = myService->getStubAdapter()->getAddress();
    std::string serviceDomain = serviceAddress.getDomain();
    std::string serviceInterface = serviceAddress.getInterface();
    std::string serviceInstance = serviceAddress.getInstance();

    runtime->unregisterService(serviceDomain, serviceInterface, serviceInstance);
}