Skip to content

Commit

Permalink
Failsafe when Servus implementation can't created and fallback to dum…
Browse files Browse the repository at this point in the history
…my (#80)
  • Loading branch information
hernando authored Oct 11, 2017
1 parent 8d47578 commit 2e9a23a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ add_subdirectory(apps)
add_subdirectory(tests)

set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libavahi-client3, avahi-daemon")
set(SERVUS_PACKAGE_DEB_DEPENDS)
if (avahi-client_FOUND)
list(APPEND SERVUS_PACKAGE_DEB_DEPENDS libavahi-client3 avahi-daemon)
endif()
include(CommonCPack)

set(COMMON_PROJECT_DOMAIN eu.humanbrainproject)
Expand Down
2 changes: 2 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

# git master

* [80](https://github.com/HBPVis/Servus/pull/80):
Failsafe when Servus implementation can't be created and fallback to dummy.
* [77](https://github.com/HBPVis/Servus/pull/77):
Add test driver implementation for Servus
* [76](https://github.com/HBPVis/Servus/pull/76):
Expand Down
15 changes: 12 additions & 3 deletions servus/servus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,21 @@ std::unique_ptr<Servus::Impl> _chooseImplementation(const std::string& name)
{
if (name == TEST_DRIVER)
return std::unique_ptr<Servus::Impl>(new test::Servus);
try
{
#ifdef SERVUS_USE_DNSSD
return std::unique_ptr<Servus::Impl>(new dnssd::Servus(name));
return std::unique_ptr<Servus::Impl>(new dnssd::Servus(name));
#elif defined(SERVUS_USE_AVAHI_CLIENT)
return std::unique_ptr<Servus::Impl>(new avahi::Servus(name));
return std::unique_ptr<Servus::Impl>(new avahi::Servus(name));
#endif
return std::unique_ptr<Servus::Impl>(new none::Servus(name));
return std::unique_ptr<Servus::Impl>(new none::Servus(name));
}
catch (const std::runtime_error& error)
{
std::cerr << "Error starting Servus client: " << error.what()
<< std::endl;
return std::unique_ptr<Servus::Impl>(new servus::none::Servus(name));
}
}
}

Expand Down

0 comments on commit 2e9a23a

Please sign in to comment.