Skip to content

Commit

Permalink
Merge pull request #134 from Helvio88/stable
Browse files Browse the repository at this point in the history
mDNS makes Moonlight discover Wolf
  • Loading branch information
ABeltramo authored Oct 5, 2024
2 parents 3233b32 + fa8c2b1 commit 86c19ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/moonlight-server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ set(TOML11_PRESERVE_COMMENTS_BY_DEFAULT, ON)
FetchContent_MakeAvailable(toml)
target_link_libraries_system(wolf_runner PUBLIC toml11::toml11)

# mDNS
FetchContent_Declare(
mdns_cpp
GIT_REPOSITORY https://github.com/gocarlos/mdns_cpp.git)
FetchContent_MakeAvailable(mdns_cpp)
target_link_libraries_system(wolf_runner PUBLIC mdns_cpp::mdns_cpp)

# Enet
set(CMAKE_PROJECT_INCLUDE_BEFORE "${PROJECT_SOURCE_DIR}/cmake/EnableCMP0048.cmake")
FetchContent_Declare(
Expand Down
13 changes: 13 additions & 0 deletions src/moonlight-server/wolf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <immer/array_transient.hpp>
#include <immer/map_transient.hpp>
#include <immer/vector_transient.hpp>
#include <mdns_cpp/logger.hpp>
#include <mdns_cpp/mdns.hpp>
#include <memory>
#include <platforms/hw.hpp>
#include <rest/rest.hpp>
Expand Down Expand Up @@ -463,6 +465,17 @@ void run() {
control::run_control(state::CONTROL_PORT, sessions, ev_bus);
}).detach();

// mDNS
mdns_cpp::Logger::setLoggerSink([](const std::string &msg) {
// msg here will include a /n at the end, so we remove it
logs::log(logs::trace, "mDNS: {}", msg.substr(0, msg.size() - 1));
});
mdns_cpp::mDNS mdns;
mdns.setServiceName("_nvstream._tcp.local.");
mdns.setServiceHostname(local_state->config->hostname);
mdns.setServicePort(state::HTTP_PORT);
mdns.startService();

auto audio_server = setup_audio_server(runtime_dir);
auto sess_handlers = setup_sessions_handlers(local_state, runtime_dir, audio_server);

Expand Down

0 comments on commit 86c19ea

Please sign in to comment.