Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ lib/
web/
*trace.json
compile_commands.json
user_stories
2 changes: 1 addition & 1 deletion client-sdk-rust
21 changes: 19 additions & 2 deletions src/room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
* limitations under the License.
*/

#include "livekit/room.h"

Check failure on line 17 in src/room.cpp

View workflow job for this annotation

GitHub Actions / clang-format

clang-format

code should be clang-formatted

#include <functional>
#include <chrono>
#include <thread>

#include "data_track.pb.h"
#include "ffi.pb.h"
Expand Down Expand Up @@ -112,7 +114,7 @@
}
connection_state_ = ConnectionState::Reconnecting;
}
auto fut = FfiClient::instance().connectAsync(url, token, options);
auto fut = FfiClient::instance().connectAsync(url, token, options); // [1]
try {
auto connectCb = fut.get(); // fut will throw if it fails to connect to the room

Expand Down Expand Up @@ -178,13 +180,28 @@
connection_state_ = ConnectionState::Connected;
}

// Install listener (Room is fully initialized)
// Proof that the issue is fixed
std::this_thread::sleep_for(std::chrono::seconds(1));
LK_LOG_INFO("Room::Connect: sleeping for 1 second");

// Install listener (Room is fully initialized) [2]
auto listenerId = FfiClient::instance().AddListener([this](const proto::FfiEvent& e) { OnEvent(e); });
{
const std::scoped_lock<std::mutex> g(lock_);
listener_id_ = listenerId;
}

// Tell the Rust core it can start forwarding room events. Rust parks the
// connect task after sending the ConnectCallback, so events emitted between
// the callback and the listener registration above would otherwise be
// dropped (PushEvent has no buffering).
{
proto::FfiRequest flush_req;
auto* msg = flush_req.mutable_flush_events();
msg->set_room_handle(static_cast<std::uint64_t>(owned_room.handle().id()));
(void)FfiClient::instance().sendRequest(flush_req);
}

return true;
} catch (const std::exception& e) {
// On error, set the connection_state_ to Disconnected
Expand Down
Loading
Loading