Skip to content

Commit

Permalink
fix: catch mdns exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ABeltramo committed Oct 14, 2024
1 parent c004a25 commit 1068b5c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/moonlight-server/wolf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,15 +498,19 @@ void run() {
std::thread([local_state]() { wolf::api::start_server(local_state); }).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();
try {
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();
} catch (const std::exception &e) {
logs::log(logs::error, "mDNS error: {}", e.what());
}

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 1068b5c

Please sign in to comment.