mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[hal] WS Simulation: Add message filtering capability (#5395)
This commit is contained in:
@@ -76,6 +76,16 @@ void HALSimHttpConnection::ProcessWsUpgrade() {
|
||||
}
|
||||
|
||||
void HALSimHttpConnection::OnSimValueChanged(const wpi::json& msg) {
|
||||
// Skip sending if this message is not in the allowed filter list
|
||||
try {
|
||||
auto& type = msg.at("type").get_ref<const std::string&>();
|
||||
if (!m_server->CanSendMessage(type)) {
|
||||
return;
|
||||
}
|
||||
} catch (wpi::json::exception& e) {
|
||||
fmt::print(stderr, "Error with message: {}\n", e.what());
|
||||
}
|
||||
|
||||
// render json to buffers
|
||||
wpi::SmallVector<uv::Buffer, 4> sendBufs;
|
||||
wpi::raw_uv_ostream os{sendBufs, [this]() -> uv::Buffer {
|
||||
|
||||
Reference in New Issue
Block a user