Skip to content

Commit

Permalink
Make getWebSocketUrl better
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-EEE committed Dec 7, 2023
1 parent 8631ca7 commit 46142f8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions raspberry_pi/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@
#include "car/system/lidar/LidarScanner.hpp"
#include "car/system/lidar/LidarDummy.hpp"

std::string getWebsocketUrl()
std::string getWebSocketUrl()
{
std::optional<int> maybe_port = GET_CONFIG_VALUE(port);
std::string host_name;
if (maybe_port.has_value())
{
return fmt::format("ws://{}:{}/ws/room?request=join&type=car&room_name={}", GET_CONFIG_VALUE(host), maybe_port.value(), GET_CONFIG_VALUE(room));
host_name = fmt::format("{}:{}", GET_CONFIG_VALUE(host), maybe_port.value());
}
return fmt::format("ws://{}/ws/room?request=join&type=&room_name={}", GET_CONFIG_VALUE(host), GET_CONFIG_VALUE(room));
else
{
host_name = GET_CONFIG_VALUE(host);
}
return fmt::format("ws://{}/ws/room?request=join&type=car&room_name={}", host_name, GET_CONFIG_VALUE(room));
}

int main()
Expand All @@ -33,7 +38,7 @@ int main()
spdlog::set_level(spdlog::level::off);
//test();

std::string websocket_url = getWebsocketUrl();
std::string websocket_url = getWebSocketUrl();
spdlog::info("Got websocket url: {}", websocket_url);

//std::unique_ptr<LidarDummy> scanner = std::make_unique<LidarDummy>();
Expand Down

0 comments on commit 46142f8

Please sign in to comment.