File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
ntcore/src/main/native/cpp Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -59,8 +59,18 @@ class WebSocketConnection final
5959 return m_ws.GetLastReceivedTime ();
6060 }
6161
62- void StopRead () final { m_ws.GetStream ().StopRead (); }
63- void StartRead () final { m_ws.GetStream ().StartRead (); }
62+ void StopRead () final {
63+ if (m_readActive) {
64+ m_ws.GetStream ().StopRead ();
65+ m_readActive = false ;
66+ }
67+ }
68+ void StartRead () final {
69+ if (!m_readActive) {
70+ m_ws.GetStream ().StartRead ();
71+ m_readActive = true ;
72+ }
73+ }
6474
6575 void Disconnect (std::string_view reason) final ;
6676
@@ -80,6 +90,7 @@ class WebSocketConnection final
8090
8191 wpi::WebSocket& m_ws;
8292 wpi::Logger& m_logger;
93+ bool m_readActive = true ;
8394
8495 class Stream ;
8596
Original file line number Diff line number Diff line change @@ -41,8 +41,18 @@ class UvStreamConnection3 final
4141
4242 uint64_t GetLastFlushTime () const final { return m_lastFlushTime; }
4343
44- void StopRead () final { m_stream.StopRead (); }
45- void StartRead () final { m_stream.StartRead (); }
44+ void StopRead () final {
45+ if (m_readActive) {
46+ m_stream.StopRead ();
47+ m_readActive = false ;
48+ }
49+ }
50+ void StartRead () final {
51+ if (!m_readActive) {
52+ m_stream.StartRead ();
53+ m_readActive = true ;
54+ }
55+ }
4656
4757 void Disconnect (std::string_view reason) final ;
4858
@@ -62,6 +72,7 @@ class UvStreamConnection3 final
6272 std::string m_reason;
6373 uint64_t m_lastFlushTime = 0 ;
6474 int m_sendsActive = 0 ;
75+ bool m_readActive = true ;
6576};
6677
6778} // namespace nt::net3
You can’t perform that action at this time.
0 commit comments