Skip to content

Commit 1ff1509

Browse files
committed
fix(cli): guard websocket checker dependency
1 parent bd32e80 commit 1ff1509

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/commands/ws/WsChecker.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
*/
1313
#include <vix/cli/commands/ws/WsChecker.hpp>
1414
#include <vix/cli/commands/ws/WsOutput.hpp>
15+
#ifdef VIX_CLI_HAS_WEBSOCKET
1516
#include <vix/websocket/client.hpp>
17+
#endif
1618

1719
#include <chrono>
1820
#include <condition_variable>
@@ -73,6 +75,7 @@ namespace vix::commands::ws::checker
7375
bool tls{false};
7476
};
7577

78+
#ifdef VIX_CLI_HAS_WEBSOCKET
7679
struct CheckState
7780
{
7881
std::mutex mutex;
@@ -82,6 +85,7 @@ namespace vix::commands::ws::checker
8285
bool errored{false};
8386
std::string error{};
8487
};
88+
#endif
8589

8690
enum class WsFailureKind
8791
{
@@ -662,6 +666,7 @@ namespace vix::commands::ws::checker
662666
return parsed;
663667
}
664668

669+
#ifdef VIX_CLI_HAS_WEBSOCKET
665670
bool wait_for_open_or_error(
666671
CheckState &state,
667672
std::uint64_t timeoutMs)
@@ -676,6 +681,7 @@ namespace vix::commands::ws::checker
676681
return state.opened || state.errored || state.closed;
677682
});
678683
}
684+
#endif
679685

680686
void print_parsed_url(
681687
const ParsedWsUrl &url)
@@ -761,6 +767,17 @@ namespace vix::commands::ws::checker
761767
if (!run_tcp_probe(*parsed, options.timeoutMs))
762768
return 1;
763769

770+
#ifndef VIX_CLI_HAS_WEBSOCKET
771+
output::warn(
772+
std::cout,
773+
"WebSocket client module is not available in this build");
774+
775+
output::fix(
776+
std::cout,
777+
"TCP check passed; rebuild the Vix CLI with the websocket module enabled for handshake checks");
778+
779+
return 0;
780+
#else
764781
CheckState state;
765782

766783
auto client = vix::websocket::Client::create(
@@ -883,5 +900,6 @@ namespace vix::commands::ws::checker
883900

884901
output::ok(std::cout, "WebSocket endpoint is reachable");
885902
return 0;
903+
#endif
886904
}
887905
}

0 commit comments

Comments
 (0)