mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
SCRIPT: wpiformat
This commit is contained in:
committed by
Peter Johnson
parent
ae6bdc9d25
commit
2109161534
@@ -54,7 +54,8 @@ bool HALSimWS::Initialize() {
|
||||
try {
|
||||
m_port = std::stoi(port);
|
||||
} catch (const std::invalid_argument& err) {
|
||||
wpi::util::print(stderr, "Error decoding HALSIMWS_PORT ({})\n", err.what());
|
||||
wpi::util::print(stderr, "Error decoding HALSIMWS_PORT ({})\n",
|
||||
err.what());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -71,8 +72,9 @@ bool HALSimWS::Initialize() {
|
||||
const char* msgFilters = std::getenv("HALSIMWS_FILTERS");
|
||||
if (msgFilters != nullptr) {
|
||||
m_useMsgFiltering = true;
|
||||
wpi::util::split(wpi::util::trim(msgFilters), ',', -1, false,
|
||||
[&](auto val) { m_msgFilters[wpi::util::trim(val)] = true; });
|
||||
wpi::util::split(
|
||||
wpi::util::trim(msgFilters), ',', -1, false,
|
||||
[&](auto val) { m_msgFilters[wpi::util::trim(val)] = true; });
|
||||
} else {
|
||||
m_useMsgFiltering = false;
|
||||
}
|
||||
@@ -112,7 +114,7 @@ void HALSimWS::Start() {
|
||||
|
||||
// Set up the connection timer
|
||||
wpi::util::print("Will attempt to connect to ws://{}:{}{}\n", m_host, m_port,
|
||||
m_uri);
|
||||
m_uri);
|
||||
|
||||
// Set up the timer to attempt connection
|
||||
m_connect_timer->timeout.connect([this] { AttemptConnect(); });
|
||||
|
||||
@@ -89,9 +89,9 @@ void HALSimWSClientConnection::OnSimValueChanged(const wpi::util::json& msg) {
|
||||
|
||||
wpi::util::SmallVector<uv::Buffer, 4> sendBufs;
|
||||
wpi::net::raw_uv_ostream os{sendBufs, [this]() -> uv::Buffer {
|
||||
std::lock_guard lock(m_buffers_mutex);
|
||||
return m_buffers.Allocate();
|
||||
}};
|
||||
std::lock_guard lock(m_buffers_mutex);
|
||||
return m_buffers.Allocate();
|
||||
}};
|
||||
|
||||
os << msg;
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@ class HALSimWSClientConnection
|
||||
: public HALSimBaseWebSocketConnection,
|
||||
public std::enable_shared_from_this<HALSimWSClientConnection> {
|
||||
public:
|
||||
explicit HALSimWSClientConnection(std::shared_ptr<HALSimWS> client,
|
||||
std::shared_ptr<wpi::net::uv::Stream> stream)
|
||||
explicit HALSimWSClientConnection(
|
||||
std::shared_ptr<HALSimWS> client,
|
||||
std::shared_ptr<wpi::net::uv::Stream> stream)
|
||||
: m_client(std::move(client)),
|
||||
m_stream(std::move(stream)),
|
||||
m_buffers(128) {}
|
||||
|
||||
Reference in New Issue
Block a user