diff --git a/crates/viewer/re_viewer/data/quick_start_guides/quick_start_connect.cpp b/crates/viewer/re_viewer/data/quick_start_guides/quick_start_connect.cpp index b2144eed9831f..1bdd80ab984ee 100644 --- a/crates/viewer/re_viewer/data/quick_start_guides/quick_start_connect.cpp +++ b/crates/viewer/re_viewer/data/quick_start_guides/quick_start_connect.cpp @@ -6,7 +6,7 @@ using namespace rerun::demo; int main() { // Create a new `RecordingStream` which sends data over TCP to the viewer process. const auto rec = rerun::RecordingStream("rerun_example_quick_start_connect"); - rec.connect().exit_on_failure(); + rec.connect_tcp().exit_on_failure(); // Create some data using the `grid` utility function. std::vector points = grid3d(-10.f, 10.f, 10); diff --git a/docs/snippets/all/concepts/app-model/native-sync.cpp b/docs/snippets/all/concepts/app-model/native-sync.cpp index c36bcc0faa77f..1e28f93a0f696 100644 --- a/docs/snippets/all/concepts/app-model/native-sync.cpp +++ b/docs/snippets/all/concepts/app-model/native-sync.cpp @@ -4,7 +4,7 @@ int main() { // Connect to the Rerun TCP server using the default address and // port: localhost:9876 const auto rec = rerun::RecordingStream("rerun_example_native_sync"); - rec.connect().exit_on_failure(); + rec.connect_tcp().exit_on_failure(); // Log data as usual, thereby pushing it into the TCP socket. while (true) { diff --git a/docs/snippets/all/quick_start/quick_start_connect.cpp b/docs/snippets/all/quick_start/quick_start_connect.cpp index b2144eed9831f..1bdd80ab984ee 100644 --- a/docs/snippets/all/quick_start/quick_start_connect.cpp +++ b/docs/snippets/all/quick_start/quick_start_connect.cpp @@ -6,7 +6,7 @@ using namespace rerun::demo; int main() { // Create a new `RecordingStream` which sends data over TCP to the viewer process. const auto rec = rerun::RecordingStream("rerun_example_quick_start_connect"); - rec.connect().exit_on_failure(); + rec.connect_tcp().exit_on_failure(); // Create some data using the `grid` utility function. std::vector points = grid3d(-10.f, 10.f, 10); diff --git a/examples/cpp/log_file/main.cpp b/examples/cpp/log_file/main.cpp index a1a6871bd78f4..cedba41b387d2 100644 --- a/examples/cpp/log_file/main.cpp +++ b/examples/cpp/log_file/main.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) { if (args["spawn"].as()) { rec.spawn().exit_on_failure(); } else if (args["connect"].as()) { - rec.connect().exit_on_failure(); + rec.connect_tcp().exit_on_failure(); } else if (args["stdout"].as()) { rec.to_stdout().exit_on_failure(); } else if (args.count("save")) { diff --git a/rerun_cpp/docs/readme_snippets.cpp b/rerun_cpp/docs/readme_snippets.cpp index 63dedc1f19c8d..4c55ef12418dc 100644 --- a/rerun_cpp/docs/readme_snippets.cpp +++ b/rerun_cpp/docs/readme_snippets.cpp @@ -45,7 +45,7 @@ static std::vector create_image() { [[maybe_unused]] static void connecting() { /// [Connecting] rerun::RecordingStream rec("rerun_example_app"); - auto result = rec.connect(); // Connect to local host with default port. + auto result = rec.connect_tcp(); // Connect to local host with default port. if (result.is_err()) { // Handle error. } diff --git a/rerun_cpp/src/rerun/recording_stream.cpp b/rerun_cpp/src/rerun/recording_stream.cpp index 88de76f098729..6e4beb2735727 100644 --- a/rerun_cpp/src/rerun/recording_stream.cpp +++ b/rerun_cpp/src/rerun/recording_stream.cpp @@ -101,6 +101,10 @@ namespace rerun { } Error RecordingStream::connect(std::string_view tcp_addr, float flush_timeout_sec) const { + return RecordingStream::connect_tcp(tcp_addr, flush_timeout_sec); + } + + Error RecordingStream::connect_tcp(std::string_view tcp_addr, float flush_timeout_sec) const { rr_error status = {}; rr_recording_stream_connect( _id, diff --git a/rerun_cpp/src/rerun/recording_stream.hpp b/rerun_cpp/src/rerun/recording_stream.hpp index 854b561d7487b..f07549fde1e7c 100644 --- a/rerun_cpp/src/rerun/recording_stream.hpp +++ b/rerun_cpp/src/rerun/recording_stream.hpp @@ -143,8 +143,23 @@ namespace rerun { /// timeout, and can cause a call to `flush` to block indefinitely. /// /// This function returns immediately. - Error connect(std::string_view tcp_addr = "127.0.0.1:9876", float flush_timeout_sec = 2.0) - const; + [[deprecated("Use `connect_tcp` instead")]] Error connect( + std::string_view tcp_addr = "127.0.0.1:9876", float flush_timeout_sec = 2.0 + ) const; + + /// Connect to a remote Rerun Viewer on the given ip:port. + /// + /// Requires that you first start a Rerun Viewer by typing 'rerun' in a terminal. + /// + /// flush_timeout_sec: + /// The minimum time the SDK will wait during a flush before potentially + /// dropping data if progress is not being made. Passing a negative value indicates no + /// timeout, and can cause a call to `flush` to block indefinitely. + /// + /// This function returns immediately. + Error connect_tcp( + std::string_view tcp_addr = "127.0.0.1:9876", float flush_timeout_sec = 2.0 + ) const; /// Spawns a new Rerun Viewer process from an executable available in PATH, then connects to it /// over TCP. diff --git a/rerun_cpp/tests/recording_stream.cpp b/rerun_cpp/tests/recording_stream.cpp index 691998ff7d0e3..1eb96c53d0048 100644 --- a/rerun_cpp/tests/recording_stream.cpp +++ b/rerun_cpp/tests/recording_stream.cpp @@ -264,13 +264,13 @@ SCENARIO("RecordingStream can be used for logging archetypes and components", TE THEN("an archetype can be logged") { stream.log( "log_archetype-splat", - rerun::Points2D({rerun::Vec2D{1.0, 2.0}, rerun::Vec2D{4.0, 5.0}} - ).with_colors(rerun::Color(0xFF0000FF)) + rerun::Points2D({rerun::Vec2D{1.0, 2.0}, rerun::Vec2D{4.0, 5.0}}) + .with_colors(rerun::Color(0xFF0000FF)) ); stream.log_static( "log_archetype-splat", - rerun::Points2D({rerun::Vec2D{1.0, 2.0}, rerun::Vec2D{4.0, 5.0}} - ).with_colors(rerun::Color(0xFF0000FF)) + rerun::Points2D({rerun::Vec2D{1.0, 2.0}, rerun::Vec2D{4.0, 5.0}}) + .with_colors(rerun::Color(0xFF0000FF)) ); } @@ -380,14 +380,14 @@ void test_logging_to_connection(const char* address, const rerun::RecordingStrea AND_GIVEN("an invalid address for the socket address") { THEN("then the save call fails") { CHECK( - stream.connect("definitely not valid!", 0.0f).code == + stream.connect_tcp("definitely not valid!", 0.0f).code == rerun::ErrorCode::InvalidSocketAddress ); } } AND_GIVEN("a valid socket address " << address) { THEN("save call with zero timeout returns no error") { - REQUIRE(stream.connect(address, 0.0f).is_ok()); + REQUIRE(stream.connect_tcp(address, 0.0f).is_ok()); WHEN("logging a component and then flushing") { check_logged_error([&] { @@ -491,17 +491,13 @@ SCENARIO("Recording stream handles serialization failure during logging graceful THEN("calling log with an array logs the serialization error") { check_logged_error( - [&] { - stream.log(path, std::array{component, component}); - }, + [&] { stream.log(path, std::array{component, component}); }, expected_error.code ); } THEN("calling log with a vector logs the serialization error") { check_logged_error( - [&] { - stream.log(path, std::vector{component, component}); - }, + [&] { stream.log(path, std::vector{component, component}); }, expected_error.code ); } @@ -643,8 +639,8 @@ SCENARIO("Deprecated log_timeless still works", TEST_TAG) { THEN("an archetype can be logged") { stream.log_timeless( "log_archetype-splat", - rerun::Points2D({rerun::Vec2D{1.0, 2.0}, rerun::Vec2D{4.0, 5.0}} - ).with_colors(rerun::Color(0xFF0000FF)) + rerun::Points2D({rerun::Vec2D{1.0, 2.0}, rerun::Vec2D{4.0, 5.0}}) + .with_colors(rerun::Color(0xFF0000FF)) ); } } diff --git a/tests/cpp/plot_dashboard_stress/main.cpp b/tests/cpp/plot_dashboard_stress/main.cpp index fab96506f774f..e3181c01b895f 100644 --- a/tests/cpp/plot_dashboard_stress/main.cpp +++ b/tests/cpp/plot_dashboard_stress/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char** argv) { if (args["spawn"].as()) { rec.spawn().exit_on_failure(); } else if (args["connect"].as()) { - rec.connect().exit_on_failure(); + rec.connect_tcp().exit_on_failure(); } else if (args["stdout"].as()) { rec.to_stdout().exit_on_failure(); } else if (args.count("save")) {