Skip to content

Commit

Permalink
Temporary fix for TimeSyncMessage invalid json serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Sep 7, 2023
1 parent 2079d64 commit 746e8e6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/v2i-hub/CARMAStreetsPlugin/src/CARMAStreetsPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,17 @@ void CARMAStreetsPlugin::OnConfigChanged(const char *key, const char *value) {
void CARMAStreetsPlugin::HandleTimeSyncMessage(tmx::messages::TimeSyncMessage &msg, routeable_message &routeableMsg ) {
PluginClientClockAware::HandleTimeSyncMessage(msg, routeableMsg);
if ( isSimulationMode()) {
PLOG(logINFO) << "Handling TimeSync messages!" << std::endl;
produce_kafka_msg(msg.to_string(), "time_sync");
// TODO: This is a temporary fix for tmx message container property tree
// serializing all attributes as strings. This issue needs to be fixed but
// is currently out of scope. TMX Messages should be correctly serialize to
// and from json. This temporary fix simply using regex to look for numeric,
// null, and bool values and removes the quotations around them.
boost::regex exp("\"(null|true|false|[0-9]+(\\.[0-9]+)?)\"");
std::stringstream ss;
std::string rv = boost::regex_replace(msg.to_string(), exp, "$1");
PLOG(logINFO) << "Sending Time Sync Message " << rv << std::endl;

produce_kafka_msg(rv, "time_sync");
}
}
void CARMAStreetsPlugin::HandleMobilityOperationMessage(tsm3Message &msg, routeable_message &routeableMsg ) {
Expand Down

0 comments on commit 746e8e6

Please sign in to comment.