Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++: add missing implementations for client advertised schema/encoding #876

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion cpp/foxglove-websocket/include/foxglove/websocket/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ struct ClientAdvertisement {
std::string topic;
std::string encoding;
std::string schemaName;
std::vector<uint8_t> schema;
std::optional<std::string> schema;
std::optional<std::string> schemaEncoding;
};

struct ClientMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ inline void to_json(nlohmann::json& j, const ClientAdvertisement& p) {
{"topic", p.topic},
{"encoding", p.encoding},
{"schemaName", p.schemaName}};
if (p.schema) {
j["schema"] = *p.schema;
}
if (p.schemaEncoding) {
j["schemaEncoding"] = *p.schemaEncoding;
}
}

using TextMessageHandler = std::function<void(const std::string&)>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,12 @@ void Server<ServerConfiguration>::handleAdvertise(const nlohmann::json& payload,
advertisement.topic = topic;
advertisement.encoding = chan.at("encoding").get<std::string>();
advertisement.schemaName = chan.at("schemaName").get<std::string>();
if (chan.contains("schema")) {
*advertisement.schema = chan.at("schema").get<std::string>();
}
if (chan.contains("schemaEncoding")) {
*advertisement.schemaEncoding = chan.at("schemaEncoding").get<std::string>();
}

clientPublications.emplace(channelId, advertisement);
{
Expand Down
Loading