Skip to main content
Version: 0.0.x

C++ SDK Events

onParticipantJoined()

The onParticipantJoined event listener is triggered when a remote participant joins the meeting. It receives the participant's ID and display name.

Parameters

  • callback
    • type: std::function<void(const std::string& id, const std::string& name)>
    • REQUIRED

Example

meeting.onParticipantJoined([](const std::string& id, const std::string& name) {
std::cout << "Participant joined: " << name << " (" << id << ")" << std::endl;
});

onParticipantLeft()

The onParticipantLeft event listener is triggered when a remote participant leaves the meeting.

Parameters

  • callback
    • type: std::function<void(const std::string& id)>
    • REQUIRED

Example

meeting.onParticipantLeft([](const std::string& id) {
std::cout << "Participant left: " << id << std::endl;
});

onError()

The onError event listener is triggered when an unrecoverable error occurs during the meeting session.

Parameters

  • callback
    • type: std::function<void(videosdk::ErrorCode code, const std::string& message)>
    • REQUIRED

Example

meeting.onError([](videosdk::ErrorCode code, const std::string& message) {
std::cerr << "Error: " << message << std::endl;
});

onData()

The onData event listener is triggered when a data message is received from another participant over the data channel. The callback mirrors sendData()'s shape — data/len are the raw payload bytes (valid only for the duration of the callback, so copy them out if you need to keep them), and is_binary mirrors the sender's text/binary flag. For text frames, the bytes are UTF-8.

Parameters

  • callback
    • type: std::function<void(const uint8_t* data, size_t len, bool is_binary)>
    • REQUIRED

Example

meeting.onData([](const uint8_t* data, size_t len, bool is_binary) {
if (is_binary) {
std::printf("Received %zu binary bytes\n", len);
} else {
std::string text(reinterpret_cast<const char*>(data), len);
std::cout << "Received text: " << text << std::endl;
}
});

Got a Question? Ask us on discord