MCPcopy Create free account
hub / github.com/OpenImageDebugger/OpenImageDebugger / start

Method start

src/oidbridge/oid_bridge.cpp:98–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96 : plot_callback_{std::move(plot_callback)} {}
97
98 bool start() {
99 // The user may have closed a previous window: its process is gone and
100 // its socket is dead. Drop the stale transport so wait_for_client()
101 // below accepts the fresh window's connection; otherwise client_
102 // keeps pointing at the dead socket, the new window is never adopted,
103 // and every send fails. Checked via the process (not just the socket)
104 // because a dead window's socket can still report readable leftover
105 // data.
106 if (client_ != nullptr &&
107 (!ui_proc_.isRunning() || !client_->is_connected())) {
108 client_.reset();
109 }
110 // acceptor_ already listens on an ephemeral port (all interfaces)
111 // as part of its construction.
112 const auto portStdString = std::to_string(acceptor_.port());
113
114 // The viewer parses only -h/-p. Process::start() takes a non-const
115 // reference (it builds a mutable argv from the strings' data()), so
116 // command cannot be const here.
117 std::vector<std::string> command = {
118 oid_path_ + "/oidwindow", "-p", portStdString};
119
120 ui_proc_.start(command);
121
122 ui_proc_.waitForStart();
123
124 wait_for_client();
125
126 return client_ != nullptr;
127 }
128
129 void set_path(const std::string_view& oid_path) {
130 oid_path_ = oid_path;

Callers 1

oid_execFunction · 0.45

Calls 4

is_connectedMethod · 0.80
portMethod · 0.80
waitForStartMethod · 0.80
isRunningMethod · 0.45

Tested by

no test coverage detected