Skip to content

Commit

Permalink
C++: add missing implementations for client advertised schema/encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsohn committed Nov 13, 2024
1 parent a28e0b9 commit 3df102a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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

0 comments on commit 3df102a

Please sign in to comment.