Skip to content

Commit

Permalink
[ntcore] Fix EALREADY errors by tracking read state
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJohnson committed Oct 13, 2024
1 parent 1288501 commit 5e768e9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ntcore/src/main/native/cpp/net/WebSocketConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,18 @@ class WebSocketConnection final
return m_ws.GetLastReceivedTime();
}

void StopRead() final { m_ws.GetStream().StopRead(); }
void StartRead() final { m_ws.GetStream().StartRead(); }
void StopRead() final {
if (m_readActive) {
m_ws.GetStream().StopRead();
m_readActive = false;
}
}
void StartRead() final {
if (!m_readActive) {
m_ws.GetStream().StartRead();
m_readActive = true;
}
}

void Disconnect(std::string_view reason) final;

Expand All @@ -80,6 +90,7 @@ class WebSocketConnection final

wpi::WebSocket& m_ws;
wpi::Logger& m_logger;
bool m_readActive = true;

class Stream;

Expand Down

0 comments on commit 5e768e9

Please sign in to comment.